dcsimg
A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: connection between flash and mysql

  1. #1
    Junior Member
    Join Date
    Apr 2015
    Posts
    2

    connection between flash and mysql

    i use this code to insert data from flash to mysql


    Here is part of the AS3 code:

    Code:
    var variables:URLVariables = new URLVariables;
    var varSend:URLRequest = new URLRequest("register.php");
    varSend.method = URLRequestMethod.POST;
    varSend.data = variables;
    var varLoader:URLLoader = new URLLoader;
    varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
    variables.userName = user_txt.text;
    variables.userPass = pass_txt.text;
    variables.userEmail = email_txt.text;
    varLoader.load(varSend);

    Here is the php script "register.php":

    PHP Code:
    <?php

    $db_host 
    "localhost";
    $db_username "root"
    $db_pass ""
    $db_name "userregister";

    mysql_connect("$db_host","$db_username","$db_pass) or die ("could not connect to mysql");
    mysql_select_db("$db_name") or die ("no database");

    $senderName $_POST['userName'];
    $senderPass $_POST['userPass'];
    $senderEmail $_POST['userEmail'];

    $sqlCommand "INSERT INTO user (username, password, email)
    VALUES('
    $senderName','$senderPass','$senderEmail') ";

    $query mysql_query($sqlCommand) or die (mysql_error());

    $my_msg "Thanks $senderName, all data has been sent.";

    echo 
    "return_msg=$my_msg";

    ?>
    my question is :

    1- how i can search for a username and update data user ?
    2- how i can show username from a list and sorting ?


    thank you very very much for help me

  2. #2
    . fruitbeard's Avatar
    Join Date
    Oct 2011
    Posts
    1,785
    Hi,

    Without modifying your code too much you can probably figure out what to do from this code.
    You can search for a certain name and password, then display that relevant data, you can also insert it the way you already did after finding the user and password match.

    PHP Code:
    <?php

    $db_host 
    "localhost";
    $db_username "root"
    $db_pass ""
    $db_name "userregister";

    mysql_connect("$db_host","$db_username","$db_pass) or die ("could not connect to mysql");
    mysql_select_db("$db_name") or die ("no database");

    $senderName $_POST['userName'];
    $senderPass $_POST['userPass'];
    $senderEmail $_POST['userEmail'];

    $searchString "SELECT * FROM users WHERE username='$senderName' AND password='$senderPass'";
    $result mysql_query($searchString)

    or die(
    $searchString."<br/><br/>".mysql_error());

    if (
    mysql_num_rows($result))
    {
        while (
    $data mysql_fetch_array($result))
        {
            
    $userNameData $data['username'];
            
    $userPassData $data['password'];
            
    $userMailData $data['email'];
            echo 
    "Data=Your username is ".$userNameData.".\nYour password is ".$userPassData."\nYour email is ".$userMailData.".";
        }
        
    mysql_close($db_name);
    }
    else
    {
        echo 
    "Data=Nothing found with this username and password.";
        
    mysql_close($db_name);
    }

    ?>
    Last edited by fruitbeard; 04-27-2015 at 08:17 AM.

  3. #3
    Junior Member
    Join Date
    Apr 2015
    Posts
    2
    Thank you

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center