This question already has an answer here:
EDIT:
Hi I am trying to build a form and check if the email address is already taken during the sign up process. Currently I am trying this on my localhost. But whenever I sign up it says
Could not sign up.
Where am I mistaking? PHP code:
<?php
if (array_key_exists("submit", $_POST)) {
$link = mysqli_connect("localhost", "root", "root", "form");
if (mysqli_connect_error()) {
die ("Database Connection Error");
}
else {
$query = "SELECT id FROM 'users' WHERE email = '".mysqli_real_escape_string($link, $_POST['email'])."' LIMIT 1";
$result = mysqli_query($link, $query);
if (mysqli_num_rows($result) > 0) {
echo "That email address is taken.";
}
else {
$query = "INSERT INTO 'users' ('name', 'email', 'password', 'number') VALUES ('".mysqli_real_escape_string($link, $_POST['name'])."', '".mysqli_real_escape_string($link, $_POST['email'])."', '".mysqli_real_escape_string($link, $_POST['password'])."', '".mysqli_real_escape_string($link, $_POST['number'])."')";
if (!mysqli_query($link, $query)) {
echo "Could not sign up.";
}
else {
echo "Sign up successful.";
}
}
}
}
?>
</div>