PHP IF condition advise needed
Posted
by
Jose David Garcia Llanos
on Stack Overflow
See other posts from Stack Overflow
or by Jose David Garcia Llanos
Published on 2012-04-13T17:07:19Z
Indexed on
2012/04/13
17:28 UTC
Read the original article
Hit count: 427
I'm using emails as username to login into a site being developed, now if a user updates their email from the profile page, how can i make sure that my email checking statement doesnt catch the user's email as already registered in the database.
the page
/* Now we will store the values submitted by form in variable */
$fullname=$_POST['fullname'];
$dob=$_POST['dob'];
$address=$_POST['address'];
$myusername=$_POST['myusername'];
$telephone=$_POST['telephone'];
$queryuser=mysql_query("SELECT * FROM customer WHERE email='$myusername' ");
$checkuser=mysql_num_rows($queryuser);
if($checkuser != 0)
{
$Merr[]='» Sorry this email is already registered!';
}
else {$insert_user=mysql_query("UPDATE CUSTOMER SET SYNTAX HERE");
Now these are the fields in question;
(name, dob, address, email, telephone) VALUES ('$fullname', '$dob', '$address', '$myusername', '$telephone')
As you can see if the user changes the login email then the syntax checks for the email being submitted against the database, however if the user leaves the email unchanged he will get the error because it is found in the database.
I was thinking of something like;
if($checkuser != 0) {
if($myusername == $_POST['myusername'])
(...dont show error.)
but my php skills are limited. can anyone advise please, thanks
© Stack Overflow or respective owner