I a have update form for account information. Under one form i have name, username, email, company, password. Let’s say all i want to do is change my name, i still use that form and all other fields stay the same. In the update form i have an email and username checker which make sure they aren’t already taken. So now, even if i don’t change my email address or username its getting submitted to the checker code.
How can I fix it so that it doesn’t prevent it if it belongs to the same person:
// checks if the email is in use
if (!get_magic_quotes_gpc()) {
$_POST['email'] = addslashes($_POST['email']);
}
$emailcheck = $_POST['email'];
$check = mysql_query("SELECT email FROM accounts WHERE email = '$emailcheck'")
or die(mysql_error());
$check2 = mysql_num_rows($check);
//if the name exists it gives an error
if ($check2 != 0) {
print("here i basically show the form once again highlighting the error)");
die('');
}
i dont know how ur db is formatted but add username to sql should do it
Therefore it will look where the email is not in the row of that specific user 🙂