I'm following Rob Percival's 'The Complete Web Developer Course' and I'm stuck on lecture 206, where you create a form asking for an email and passwords, and it inserts it into a MySQL database. The instructor corrects some of the code 'off camera', so I can't double check my code.
When I press submit to my form, it appears successful, but nothing is added to my database.I have checked with other users and they have the same query written, and I have also included a check to see that the connection to the database was successful.
$link = mysqli_connect("localhost", "cl22-megadb", "xGKCe.bcB", "cl22-megadb");
if (mysqli_connect_error()) {
die("Could not connect");
}
$query = "SELECT * FROM users WHERE email='".mysqli_real_escape_string($link, $_POST['email'])."'";
$result = mysqli_query($link, $query);
$results = mysqli_num_rows($result);
if ($results) echo "That email adress is already registered. Do you want to login?";
else {
$query = "INSERT INTO 'users' (`email`, `password`) VALUES('".mysqli_real_escape_string($link, $_POST['email'])."','".md5(md5($_POST['email']).$_POST['password'])."')";
mysqli_query($link, $query);
echo "You've been signed up!";
}
}
}
?>
<form method="post">
<input type="email" name="email" id="email" />
<input type="password" name="password" id="password" />
<input type="submit" name="submit" value="Sign Up" />
</form>
Is there a MySql log or something else I can check in order to investigate what actually happens to my MySql insertion attempt?