I've searched for something similar to my question, they all used mysqli
while I am using PDO
. (I am not sure if it differs between them)
if(!empty($_POST['username']) && !empty($_POST['email']) && !empty($_POST['password'])):
if (mysql_num_rows($check_username) != 0):
echo "Username already exists";
else:
$stmt = $conn->prepare($registration_insert);
$stmt->bindParam(':username', $_POST['username']);
$stmt->bindParam(':email', $_POST['email']);
$stmt->bindParam(':password', password_hash($_POST['password'], PASSWORD_BCRYPT));
if( $stmt->execute() ):
$message = 'Successfully created new user';
else:
$message = 'Sorry there must have been an issue creating your account';
endif;
endif;
endif;
$check_username
has the value of
SELECT * FROM users WHERE username='".$username."'"
This code outputs:
Warning: mysql_num_rows() expects parameter 1 to be resource, string given in path:\to\my\wesbite\signup.php on line 15
line 15 =
if (mysql_num_rows($check_username) > != 0):