A Flash Developer Resource Site

Results 1 to 3 of 3

Thread: Flash and PHP Going to another frame with correct login

  1. #1
    Junior Member
    Join Date
    Mar 2011

    Flash and PHP Going to another frame with correct login

    Hello and thank you for helping me! Here's my problem. I don't get any errors, but I don't get any results either. When I put in a password and a username. I don't get a message back. Whether it's right or wrong. So, why isn't this working? If the user and/or password is wrong. I want it to display No good in the status_txt. If it's right I want it go to and stop on frame 2. But it doesn't seem to work. status_txt is working because if I don't put anything in and press the button I get the message "Please enter your username." Like I want it to. Thanks in advance

    In my timeline I have the following code:

    //email_txt.tabIndex = 1;
    //password_txt.tabIndex = 2;
    //sumbit_btn.tabIndex = 3;
    // Assign a variable name for our URLVariables object
    var variables:URLVariables = new URLVariables();
    //  Build the varSend variable
    var varSend:URLRequest = new URLRequest("login.php");
    varSend.method = URLRequestMethod.POST;
    varSend.data = variables;
    // Build the varLoader variable
    var varLoader:URLLoader = new URLLoader;
    varLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
    varLoader.addEventListener(Event.COMPLETE, completeHandler);
    // Handler for PHP script completion and return
    function completeHandler(event:Event):void{
    	status_txt.text ="";
    	if (event.target.data.return_msg == "no_good") {
    			status_txt.text = "No match in our records, please try again";
    	} else if (event.target.data.return_msg == "all_good") {
    // Add an event listener for the submit button and what function to run
    submit_button.addEventListener(MouseEvent.CLICK, ValidateAndSend);
    // Validate form fields and send the variables when submit button is clicked
    function ValidateAndSend(event:MouseEvent):void{
    	status_txt.text ="";
        //validate form fields
        if(!username.length) {
    		status_txt.text = "Please enter your username.";	
    	} else if(!password.length) {
    		status_txt.text = "Please enter your password.";	
    	} else {
    		// Ready the variables for sending
       		variables.username = username.text;
       		variables.pass = password.text;
    		// Send the data to the php file
    		status_txt.text = "Processing...";
    	} // close else after form validation
    } // Close ValidateAndSend function //////////////////////////////////////////////////////////////
    Here's my PHP code

    PHP Code:
    if ($_POST['username'] != "") {


    $username $_POST['username'];
    $pass $_POST['pass'];

    $username strip_tags($username);
    $pass strip_tags($pass);
    $username mysql_real_escape_string($username);
    $pass mysql_real_escape_string($pass);
    $username eregi_replace("`"""$username);
    $pass eregi_replace("`"""$pass);

    $pass md5($pass);

    //make query
    $sql mysql_query("SELECT * FROM users WHERE username='$username' AND password='$pass'); 
    $login_check = mysql_num_rows($sql);

    $login_check > 0){ 

    $row = mysql_fetch_array($sql)){ 

    $my_msg = "all_good";
            print "
        } // close while
    } else {
    $my_msg = "no_good";
        print "

    }// close if post

  2. #2
    Senior Member
    Join Date
    Jul 2002
    Are you trying this locally?
    If you are trying locally, you need something like WAMP to create a localhost for PHP to work.

  3. #3
    Junior Member
    Join Date
    Mar 2011
    Yeah I'm trying this locally and I have WAMP installed and I have the files in the www directory. PHP is working fine. Still having this problem

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