Forum Moderators: coopster

Message Too Old, No Replies

PHP and Validation

         

Modern Merlin

10:56 am on Jul 18, 2008 (gmt 0)

10+ Year Member



I recently started a website and the building there of. I have a registration page in Flash CS3 with AS2. When I go to try register I get a response saying thank you for registering.

The only problem is that I have already registered with that very email address several times now and the PHP code is supposed to check to make sure the username, password and email are not already in the DB. It isnt doing that however. Its almost as if its totally skipping over that code all together and then writing it back to the DB (the same email addy over and over again).

Here is the code to check for the email addy

$SQL = "SELECT * account WHERE email ='".$email."'";

$rs = mysql_query($SQL,$conn);

$numRows = mysql_num_rows($rs);
if($numRows > 0){
echo 'result=emailExists';
exit('&result=emailExists&');//abort php script
}

Any suggestions?

henry0

11:25 am on Jul 18, 2008 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



"WHERE" from are you selecting?

SELECT * account WHERE email ='".$email."'

correct:
SELECT *
FROM
account WHERE email ='".$email."'

also from a SQL labor stand point of view
avoid as much as possible *
instead specify what are the really required fields
and to keep it simple
I'll rather do ='$email'

<edit>
forgot about a simple debug check:
echo your query for example in phpmyadmin
copy and paste in phpmyadmin SQL tab:
SELECT *
FROM
account WHERE email ='".$email."'

and watch the error popping up :)</edit>

Modern Merlin

11:59 am on Jul 18, 2008 (gmt 0)

10+ Year Member



OMG LOL I cannot believe I missed that! Thats what I get for now sleep LOL Thanks!

Modern Merlin

12:05 pm on Jul 18, 2008 (gmt 0)

10+ Year Member



Its working perfectly now... Thanks so much!

[edited by: Modern_Merlin at 12:06 pm (utc) on July 18, 2008]