PDA

View Full Version : Flash Form not re-submitting.


Shabalaka
07-30-2008, 09:15 PM
Hi i have been trying to do a login application which sends the user to a page upon correct login information and displays a flash msg if incorrect , Now what is happening is that the form in flash seems to submit only once so if you get the login wrong the value returned from the PHP is always &Answer="No"&
The flash code:
// create an instance of LoadVars to send data
var dataOut:LoadVars = new LoadVars();
var dataIn:LoadVars = new LoadVars();
// Place a counter which should increase if the user attempts to login more than once.
var attempt:Number = new Number();
attempt = 0;
dataIn.onLoad = function (){
if(this.Answer == "No"){
attempt = attempt+1;
statusmsg.text ="You were not authorised, Login trys "+attempt;
trace(this.Answer);
}else{
statusmsg.text = "Authorised";
}
}

function checkUser():Void {
dataOut.username = username.text;
dataOut.password = password.text;
dataOut.sendAndLoad("http://localhost/Examples/flash1.php", dataIn, "POST");
}

enterbtn.addEventListener("click", checkUser);


The PHP page code
$username = $_POST['username'];
$password = $_POST['password'];
if(($username != "Test") && ($password != "Testing")){
echo "&Answer=No&";
print_r($_POST);
}else{
echo "&Answer=Yes&";
}

Please help i cant see why the flash form is not submitting more than once to the PHP page??.

Thx Shab. :)

Cota
07-30-2008, 09:20 PM
It may be retaining the old values, which is why it keeps saying no. Give this a try, see if it changes anything

dataOut.sendAndLoad("http://localhost/Examples/flash1.php?t="+random(1000), dataIn, "POST");

Shabalaka
07-30-2008, 09:25 PM
Thanks for your suggestion i tried that and i still receive "No" in the trace. When i try it on my local webserver i entered dummy data in the fields i received this message from my textarea

You were not authorised, Login trys 1

and no matter how many times i click Login it remains at 1 as if its not running the function more than once ?

Thx :)