I'm sending data to a php doc with jquery ajax. The first check ($check_user_exists) on the user's inputs is to see if there's an account under the same $email. I've tried writing a function before the if statement but that didn't work either.
I'm getting the following error:
Parse error: syntax error, unexpected 'return' (T_RETURN) in C:\xampp\htdocs\workflow\ajax\register.php on line 8
Thanks ahead of time! Here's the code:
if (isset($_POST['email']) && isset($_POST['firstname']) && isset($_POST['lastname']) && isset($_POST['role']) && isset($_POST['pw'])){
$email = strtolower($_POST['email']);
$firstname = $_POST['firstname'];
$lastname = $_POST['lastname'];
$pw = crypt($_POST['pw'], md5($email));
$role = $_POST['role'];
$check_user_exists = return (mysql_result(mysql_query("SELECT `user_id` FROM `users` WHERE user_id = '$email.'"), 0)==1) ? true : false;
if($check_user_exists === true){
echo 'Our records show an account already exists under this email.';
}
mysql_num_rows()would cut down your code by no less than 30%.mysql_result()returns the contents of theuser_idfield. Since your user IDs are apparently their email, not an identifier number, it will never be== 1.