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
Hi ,Jubba,
Thanks for that, but I have already been there and checked my code against thiers - basically it is the same. The code either side of that shown below works fine, i.e the db is found and opened and the $name is inserted with a success message going back to Flash, however, for reasons I cannot see/work out, the code for checking if the $name exists already is simple being by passed.
I am happy to post my php file if any one has the time to take a look
Why does it need to be done in Flash? I know there is a lot of temptation to do everything in Flash, especially with database manipulation, however it is not really a smart idea. It can lead to update issues and lots of problems in the future. I would suggest just printing it up on a good looking PHP page… Just my opinion…
So you are finding if the variable exists, but you just can’t get the message into the Flash movie? You have to make the Flash movie go to a loop where it tests if the variable exists and then displays the message…
Hi Jubba
In answer to your first point, Flash is only the front end and sends the vars with Load vars ( or loadVariiablesNum) - I can’t really see any furutre probs with this. I don’t know enough about php to build a web page ( yet - but I am beginning to think that way).
On your second point, the code to insert the username and password in the db works fine and prints a success message in Flash, but the code that checks to see if it already exists is bypassed - to date I have registered the same username and password about 35 times, when it should only register it once.
I have also checked the db to make sure that statment is correct.
So, going back to your first point, there isn’t really a prob manipulating the db from Flash, it is just this small block of code that is giving me a problem.
The worst thing is that I have ordered a book called ActionScript & PHP ( by the FriendsofEd team), but it takes a while to deliver and I need to get this project finsihed now!!!
Thanks for your suggestions and ideas
Cheers
SteveD
Creating engaging and entertaining content for designers and developers since 1998.