See comments to the question. Looks like a trivial syntax thing. A fast and dirty solution would be the following:
prepare("SELECT * FROM users WHERE email=?")){
$error = '';
$query->bind_param('s',$email);
$query->execute();
$->store_result();
if ($query->num_rows > 0) {
$error .= 'The email address is already registered!';
}else{
if (strlen($password) < 6){
$error .= 'Password must have atleast 6 characters.';
}
elseif (empty($confirm_password)){
$error .= 'Please enter confirm password.';
} else {
if (empty($error) && ($password != $confirm_password)){
$error .= 'Password did not match.';
}
}
if (empty($error)) {
$insertQuery = $db->prepare("INSERT INTO users (name,email,password)VALUES (?,?,?);");
$insertQuery->bind_param("sss", $fullname, $email, $password_hash);
$result = $insertQuery->execute();
if ($result) {
$error .= 'Your registration was successful!';
} else {
$error .= 'Something went wrong!';
}
}
}
}
$query->close();
$insertQuery->close();
mysqli_close($db);
}
Of course some
else {if ...
could be simplified by using
elseif
.