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...

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.