Hi
I was wondering the eayset way to make sure that when someone creats an account and it saves their email to the database, that the email is not here already. I didn't want to have to make a loop to check all the emails of other users. the email is the Proimary Key. I am using MySQL and PHP4
Thanks.
Just do a "SELECT email from tablename WHERE email='$email' " and see if it finds a record.
ok, thanks
if I do this
$query = "SELECT User_ID FROM users WHERE User_ID =" . $_POST['email']; $result = mysql_query($query); $row = mysql_fetch_row($result);
what will it return if there is no match?
mysql_fetch_row() returns false when there is no more data, so
$query = "SELECT User_ID FROM users WHERE User_ID =" . $_POST['email']; $result = mysql_query($query); if (mysql_fetch_row($result) ) { // there already } else { // process new registration }
hth
ok... now I'm getting
Warning: mysql_fetch_row(): supplied argument is not a valid MySQL result
nevermonde got it
just had to chance a line to
$query = 'SELECT User_ID FROM users WHERE User_ID ="' . $_POST['email'] . '"';
Thanks a TON!!
You need 's round string values in queries
$query = "SELECT User_ID FROM users WHERE User_ID ='" . $_POST['email']."'";
or, easier,
$email = $_POST['email']; $query = "SELECT User_ID FROM users WHERE User_ID = '$email' ";