I've seen this issue all over stack overflow but none of the methods helped.
Form:
<form action="login.php" method="POST">
<input name="username" type="text" placeholder="User Name">
<input name="rawpassword" type="password" placeholder="Password">
<input value="Login" type="submit">
</form>
Login.php:
// Gets user entered details from form.
if (isset($_POST['username'])) {
$username=$_POST['username'];
} else {
$username=null;
}
if (isset($_POST['rawpassword'])) {
$rawpassword=$_POST['rawpassword'];
} else {
$rawpassword=null;
}
// Hashes password through SHA-1.
$password = sha1($rawpassword);
echo "$username";
echo "$rawpassword";
echo "$password";
My problem is that the
if (isset($_POST['']))
is coming back as false and will make both variables null and echos null (nothing). But if I was to do this:
if (!isset($_POST['']))
It returns the undefined index error that everyone gets.
Help will be much appricated.