Jump to content

Hash Password Checker - (Unexpected T_ELSEIF Error)!


Codarz360

Recommended Posts

Alright, I have created a hash password checker and here is my code:

include("include.php"); // include the mySQL info!

$users = mysql_query(" SELECT * FROM User "); // Select all from the users table in the database!
while($row = mysql_fetch_array($users)) // While it fetches the users do the following...
{
if (hash("sha256", $password) == $row["Password"])
echo "Congratulations! The Hash matches the password entered into the database!";
} 
elseif (hash("sha256", $password) != $row["Password"])
{
echo "Your Hash failed to match the password entered!";
} 

 

Now for some reason this displays a totally blank page. When I turn error display on I get the error "Unexpected T_ELSEIF" on this line

elseif (hash("sha256", $password) != $row["Password"])

 

Any help is appreciated...

Alright so your saying it should look like this now:

include("include.php"); // include the mySQL info!

$users = mysql_query(" SELECT * FROM User "); // Select all from the users table in the database!
while($row = mysql_fetch_array($users)) // While it fetches the users do the following...
      {
if (hash("sha256", $password) == $row["Password"]) // If the hash matches the password echo the following...
      {
      echo "Hash correct!";
      }
elseif (hash("sha256", $password) != $row["Password"])
      {
      echo "Your Hash failed to match the password entered!";
      }
else
      die("Nothing");
      }

 

If so then all this is doing is displaying "Your Hash failed to match the password entered!" when I know for a fact it's the correct hash for the password.

I think I have fixed the original error by putting the code I had in my checkpass.php into my adduser.php script.

 

The only problem I'm having now is I'm getting notices from the PHP error system saying that I have 2 "Undefined variables" any idea's how to solve this small issue without turning off the display errors?

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.