A Flash Developer Resource Site

Results 1 to 5 of 5

Thread: [F8] Random retrieved from POST

  1. #1
    Junior Member
    Join Date
    Aug 2008
    Posts
    8

    Unhappy [F8] Random retrieved from POST

    Hi guys i have this flash form which simply sends a inputted username and password to a PHP page which tests only if the username exists at the moment in the database and then the PHP sends a response back to flash to say either yes or no and then flash puts it in the errormsg display.

    Now what i am experiencing is that the PHP page that pops up always says &login=YES& when i put in the right username but flash sometimes gets a yes but sometimes gets a &login=NO& and even sometimes a undefined :S when nothing has changed ??

    Please ignore the Age Dropdown on the form i keep meaning to remove it so it has no bearing on the POST.

    The white textarea that displays some traced out var information on the right hand side i hope will be useful to someone inhelping me resolve this....

    Username on form is Admin password can be anything as the PHP only checks for the username at the moment.

    Working URL link here to fully experience this randomness.. http://crms.no-ip.info/flash

    Sorry for the long post guys but im at my wits end with this......

    ActionScript here :
    Code:
    	stop();
    	///PHP PROCESSING LOGIN PAGE ADDRESS
    	var WebAddress:String ="http://localhost/flash/functions/login.php";
    	//Result var contains the retrieved info from PHP file.
    	//var Result = new LoadVars(); 
    	var Age:Number
    	var Username:String
    	var Userpassword:String
    
    for(var i:Number = 1; i<100; i++){
    	age.addItem(i);
    }
    	
    
    myBtn_btn.onRelease = function() {
    	 Age = age.selectedIndex+1;
    	 Username = username.text;
    	 Userpassword = userpass.text;
    	trace("You are "+Age+" years old and Your username is "+Username+ " And your password is " +Userpassword);
     	//Open page to display the information using GET because testing in the development.
    	getURL(WebAddress,"_blank","POST");
    			////////COPY/PASTEMODIFICATION FROM WEBSITE TEST CODE///////////
    
    					// here is a reference to this timeline
    var here = this
    // create an object to store the variables
    varReceiver = new LoadVars();
    // load a file
    varReceiver.load("http://localhost/flash/functions/login.php");
    // when the variables finish loading
    //trigger something
    varReceiver.onLoad = function() {
    		
    	// show some text in a text field
    	// using the loaded variables
    	//here.createTextField("t_txt", 1, 100, 100, 1, 1);
    	//here.t_txt.autoSize = true;
    	
    	//here.t_txt.text = "My first name is " + this.fName + ".\n";
    	//here.t_txt.text += "My last name is " + this.lName + ".\n";
    	//here.t_txt.text += "I'm " + this.age + " years old.";
    	errormsg.text = this.login;
    	//trace(VarReceiver);
    	myTrace.text = varReceiver;
    	};
    
    			////////////END TEST CODE///////////////
                            /////MY HAND CODED FUNCTION WHICH I COULD NOT GET TO WORK////
    			//Result.onLoad = function (success){
    			//if(success){
    				//trace("Result : "+this.Result);
    				//trace("Variables Loaded");
    				//errormsg.text += Result;
    			//}else{
    				//trace("Error loading page");
    			//}
    	///}
    	///Result.load(WebAddress);
    }
    The PHP code :
    PHP Code:
    $login ="";
    $Username ucfirst($_POST['Username']);
    $Userpassword md5($_POST['Userpassword']);

    //Search for user in DB 
    $sql = ("SELECT * FROM `users` WHERE `Username` = '".$Username."'");
    $query mysql_query($sql);
        
    $result mysql_fetch_array($query);
        if(
    $result == ""){
            
    $login "NO";
            echo 
    $result;
            }else{
            
    //write back to flash YES user is registered
            
    $login "YES";
            
    ///////
            

    Please can someone help me with this its almost 2 days of trying to get a simple send and receive from Flash/PHP going , I am considering of giving up on Flash completely.... As even the most simplest of tasks seems like a impossible task.....

    Many many thanks for those of you who take the time out to read and respond to this epic post.

    Regards Pinky.
    Last edited by Pinkmischief; 08-02-2008 at 12:38 PM.

  2. #2
    Working On An Online RPG grimm 88's Avatar
    Join Date
    Sep 2007
    Location
    Nowhere
    Posts
    280
    not sure which button im meant to be clicking, but...

    if i click register nuthing happens, if i click login, i get a 404 not found

  3. #3
    Junior Member
    Join Date
    Aug 2008
    Posts
    8
    Sorry i forgot to change the code in the Var WebAddress to crms.no-ip.info from localhost.

    The only button that should do anything is the login button , the registration button dont do anything yet as all im trying to achieve is a simple user verification system.

    Thanks for taking the time out to read my post.

    Hope it all works now

  4. #4
    FK'n_dog a_modified_dog's Avatar
    Join Date
    Apr 2003
    Location
    "aaarf"
    Posts
    9,176
    try using the LoadVars.sendAndLoad method -
    PHP Code:
    varReceiver = new LoadVars();

    varReceiver.Age age.selectedIndex+1;
    varReceiver.Username username.text;
    varReceiver.Userpassword userpass.text;
    varReceiver.sendAndLoad("http://localhost/flash/functions/login.php",varReceiver,"POST");

    varReceiver.onLoad = function(){
    errormsg.text this.login;
    myTrace.text unescape(this);
    }; 

  5. #5
    Junior Member
    Join Date
    Aug 2008
    Posts
    8

    Thumbs up

    Thank you very much for your help guys finally got it working after 2 whole days of trying

    Thanks for your help maybe now i can try to expand on it a bit more and integrate some other features like the register and more


    Much appreciated Pinky

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