SteveD
February 4th, 2003, 11:13 AM
Hi,
I am pretty new to php/mysql, have already built a couple contact forms, email forward etc etc. Jumping in the deep and ( and a dire need to complete before my newly ordered book "ActionScript and PHP" arrives).
So, What I am trying to build works like this
a user opens a registration .swf and fills in a desired username and password along with his/her email address and clicks on submit
The button action sends vars to the php which selects the db ( this bit works), if they are a new member the vars are inserted in to the db and a success message is sent back to Flash ( this bit works as well - amazed meself here), now comes the tricky bit. I want the php to check the db to see if the user name & password already exist, if they do then a message "try again" goes back to flash - now this is the bit that I cannot get to work. The block of code that checks if the vars are already in the db is completely bypassed. I feel sure it a tiny syntax problem ( if there is such a thing as tiny syntax) but for the life of me I cannot figure it out. This is the code :-
////////////////////////////////////////////////////////////////////////////////////
//this is the bit that isn't working - it is bypassed and todate I have //26 usernames the same in the db
//I need the php to check if a name already exists - if it does print out the results to flash
//see if user name exists
$query = "SELECT * FROM $table WHERE name = '$name'";
$result=mysql_query($query);
if(mysql_num_rows($result)<1){
print"&list=".urlencode("<b>Error:<b>try again")."&";
exit;
}
/////////////////////////////////////////////////////////////////////////////
Hope some kindly soul can take pity on me and put me right
Cheers
SteveD
I am pretty new to php/mysql, have already built a couple contact forms, email forward etc etc. Jumping in the deep and ( and a dire need to complete before my newly ordered book "ActionScript and PHP" arrives).
So, What I am trying to build works like this
a user opens a registration .swf and fills in a desired username and password along with his/her email address and clicks on submit
The button action sends vars to the php which selects the db ( this bit works), if they are a new member the vars are inserted in to the db and a success message is sent back to Flash ( this bit works as well - amazed meself here), now comes the tricky bit. I want the php to check the db to see if the user name & password already exist, if they do then a message "try again" goes back to flash - now this is the bit that I cannot get to work. The block of code that checks if the vars are already in the db is completely bypassed. I feel sure it a tiny syntax problem ( if there is such a thing as tiny syntax) but for the life of me I cannot figure it out. This is the code :-
////////////////////////////////////////////////////////////////////////////////////
//this is the bit that isn't working - it is bypassed and todate I have //26 usernames the same in the db
//I need the php to check if a name already exists - if it does print out the results to flash
//see if user name exists
$query = "SELECT * FROM $table WHERE name = '$name'";
$result=mysql_query($query);
if(mysql_num_rows($result)<1){
print"&list=".urlencode("<b>Error:<b>try again")."&";
exit;
}
/////////////////////////////////////////////////////////////////////////////
Hope some kindly soul can take pity on me and put me right
Cheers
SteveD