As many people, I got the error: "Notice: Undefined index: email in ...\login.php on line 8"
Line 8 being:
$email = $_POST['email'];
Where we get the 'email' from this form: (index.html)
<!DOCTYPE html>
<html>
<head>
<title>Login</title>
</head>
<body>
<form method="post" action="login.php">
E-mail: <input type="text" name="email">
Password: <input type="password" name="password">
<input type="submit" name="submit" value="submit">
</form>
Don't have an account? Create <a href="create.html">here</a>.
</body>
</html>
Login.php looks like this:
<?php
require_once("db.php");
require_once("functions.php");
if(isset($_POST['submit'])) {
global $connection;
$email = $_POST['email'];
$safe_email = mysqli_real_escape_string($connection, $email);
$password = $_POST['password'];
$query = "SELECT * FROM users WHERE email = '{$safe_email}'";
$result = mysqli_query($connection, $query);
if($row = mysqli_fetch_array($result)) {
$set_password = $row['password'];
$input_password = crypt($password, $set_password);
if($input_password == $set_password) {
echo "winnar";
} else {
echo "wrong password";
}
} else {
echo "we didn't recognise this email in our database";
}
}
?>
I checked spelling, closing tags, mistakes in ending code, searched some Stackoverflow questions, but nothing seemed to help. As if the e-mail was never POSTed, yet it should be.