#1
  1. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jan 2006
    Posts
    122
    Rep Power
    9

    How do i retrieve vaiables or a echo(""); from php?


    Hi im having some trouble with my login form. i know this script works i had it working on a website that i started to develop in php. I had a few ideas to implement some flash and decided it would be better if i did the whole website in flash. so im trying to convert the php scripts that i have written to be able to be used along with my flash document. Im scripting in AS2

    My question is how do i return the echo to the flash document to see if the was invalid or not?

    This doesn't seam to be working can someone point me in the right direction? Here is the AS

    Code:
    SubmitLogin_btn.onRelease = function() {
        //call php to verify the correct username and password
    formdata = new LoadVars();
        formdata.useremail=useremail.text;
        formdata.userpass=passwrd.text;
    	formdata.remember=remember.value;
    	formdata.send("doLogin.php", "_self", "POST"); 
    
    };
    formdata.onLoad = function(success) {
            if (success) {
                this.status.text = "Redirecting to members home.";
    			gotoAndStop(31);
    			
            } else {
               this.status.text = "Failed login attempt.";
            gotoAndStop(30);
    		}
        };
    here is the login php script... global.php is a php script to connect to the database.

    Code:
    <?php include_once("scripts/global.php");
    $message ='';
    if(isset($_POST["useremail"])) {
    	$email = $_POST['useremail'];
    	$pass = $_POST['userpass'];
    	$remember = $_POST['remember'];
    	
    	if((!$email)||(!$pass)){
    		$message = 'Please insert both fields.';
    	}else{
    		//Secure the data
    		$email = mysql_real_escape_string($email);
    		$pass =sha1($pass);
    	
    		$query = mysql_query("SELECT * FROM members WHERE email='$email' AND password='$pass' LIMIT 1")
    		or die('Could not check memeber');
    		$count_query = mysql_num_rows($query);
    		if($count_query == 0){
    		 echo "invalid"; 
    		}else{
    			$_SESSION['pass'] = $pass;
    			while($row = mysql_fetch_array($query)){
    				$username=$row['username'];
    				$id=$row['id'];
    				}
    				$_SESSION['username'] = $username;
    				$_SESSION['id'] = $id;
    				
    				if ($remember == 'yes'){
    					//SEt Cookies
    					setcookie('id_cookie',$id,time()*60*60*24*100,'/');
    					setcookie('pass_cookie',$id,time()*60*60*24*100,'/');
    					}
    		echo "success"; 			
    
    			}
    		}
    }
    
    
    
    
    ?>
    Last edited by IMaVBNoob; November 5th, 2012 at 02:24 PM.

IMN logo majestic logo threadwatch logo seochat tools logo