I am trying to write a form using Flash, PHP & MySQL. This form is for creating new accounts. What I want to be able to do is enter info into all fields, press a "submit" button, the info is inserted into a table and then the user is taken to a new html page. As it is now, I can enter info into fields, press submit and the info is successfully entered into the table.
However, it appears as if I am getting stuck in some kind of infinite loop as the submit buttons continuously clicks and I have to close the browser. I believe my problem is in my passing variables from PHP into Flash. Here is the PHP code:
<?
//this pulls the variables from the flash movie when the user hits submit
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$email=$_POST['email'];
$city=$_POST['city'];
$account=$_POST['account'];
$password=$_POST['password'];
$age=$_POST['age'];
//connect to database
if ($firstname && $lastname && $email && $city && $account && $password && $age){
$dbh=mysql_connect ("localhost", "user", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("MySQL database", $dbh);
//make query
$query = "INSERT INTO accounts (accountname, PASSWORD, FirstName, LastName, Email, City, Age) VALUES ('$account', '$password', '$firstname', '$lastname', '$email', '$city', '$age')";
$result = mysql_query( $query ) or die ("didn't query");
//see if there's an EXACT match
if ($result == 1){
print "Success&checklog=1";
} else {
print "Failure&checklog=2";
}
}
?>
Below is the ActionScript for the Submit Button:
on (release, keyPress "<Enter>") {
//checks to see if there is something in both the name
//and password
if (_root.firstnameinput.text != "" && _root.lastnameinput.text != "" && _root.emailinput.text != "" && _root.cityinput.text != "" && _root.accountinput.text != "" && _root.passwordinput.text != "" && _root.ageinput.text != "") {
loadVariablesNum("new.php", 0, "POST");
}
else {
_root.gotoAndStop(2);
_root.checklog=0;
_root.firstnameinput.text="";
_root.lastnameinput.text="";
_root.emailinput.text="";
_root.cityinput.text="";
_root.accountinput.text="";
_root.passwordinput.text="";
_root.ageinput.text="";
}
}
And here is the final bit of ActionScript which is on the first fram of the movie:
stop();
//stops the movie on the login page
Selection.setFocus(firstnameinput);
//this puts the cursor in the first box
this.onEnterFrame = function () {
if(_root.checklog == 1){
_root.getURL("home.htm");
}
if(_root.checklog == 2){
_root.gotoAndStop(2);
_root.checklog=0;
_root.firstnameinput.text="";
_root.lastnameinput.text="";
_root.emailinput.text="";
_root.cityinput.text="";
_root.accountinput.text="";
_root.passwordinput.text="";
_root.ageinput.text="";
}
}
//the onEnterFrame constantly checks to see if the PHP
//script has sent the variable 'checklog' back to the
//movie and directs the people accordingly
You can view the page and see the problem I am having at Just click on the "Create New Account" box in the green box and enter some bogus info.
Thanks in advance for any help! It is greatly appreciated.
However, it appears as if I am getting stuck in some kind of infinite loop as the submit buttons continuously clicks and I have to close the browser. I believe my problem is in my passing variables from PHP into Flash. Here is the PHP code:
<?
//this pulls the variables from the flash movie when the user hits submit
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$email=$_POST['email'];
$city=$_POST['city'];
$account=$_POST['account'];
$password=$_POST['password'];
$age=$_POST['age'];
//connect to database
if ($firstname && $lastname && $email && $city && $account && $password && $age){
$dbh=mysql_connect ("localhost", "user", "password") or die ('I cannot connect to the database because: ' . mysql_error());
mysql_select_db ("MySQL database", $dbh);
//make query
$query = "INSERT INTO accounts (accountname, PASSWORD, FirstName, LastName, Email, City, Age) VALUES ('$account', '$password', '$firstname', '$lastname', '$email', '$city', '$age')";
$result = mysql_query( $query ) or die ("didn't query");
//see if there's an EXACT match
if ($result == 1){
print "Success&checklog=1";
} else {
print "Failure&checklog=2";
}
}
?>
Below is the ActionScript for the Submit Button:
on (release, keyPress "<Enter>") {
//checks to see if there is something in both the name
//and password
if (_root.firstnameinput.text != "" && _root.lastnameinput.text != "" && _root.emailinput.text != "" && _root.cityinput.text != "" && _root.accountinput.text != "" && _root.passwordinput.text != "" && _root.ageinput.text != "") {
loadVariablesNum("new.php", 0, "POST");
}
else {
_root.gotoAndStop(2);
_root.checklog=0;
_root.firstnameinput.text="";
_root.lastnameinput.text="";
_root.emailinput.text="";
_root.cityinput.text="";
_root.accountinput.text="";
_root.passwordinput.text="";
_root.ageinput.text="";
}
}
And here is the final bit of ActionScript which is on the first fram of the movie:
stop();
//stops the movie on the login page
Selection.setFocus(firstnameinput);
//this puts the cursor in the first box
this.onEnterFrame = function () {
if(_root.checklog == 1){
_root.getURL("home.htm");
}
if(_root.checklog == 2){
_root.gotoAndStop(2);
_root.checklog=0;
_root.firstnameinput.text="";
_root.lastnameinput.text="";
_root.emailinput.text="";
_root.cityinput.text="";
_root.accountinput.text="";
_root.passwordinput.text="";
_root.ageinput.text="";
}
}
//the onEnterFrame constantly checks to see if the PHP
//script has sent the variable 'checklog' back to the
//movie and directs the people accordingly
You can view the page and see the problem I am having at Just click on the "Create New Account" box in the green box and enter some bogus info.
Thanks in advance for any help! It is greatly appreciated.