Jump to content

Mysql Login Query Not Working


garyblackpool
 Share

Recommended Posts

Hi,Could someone help me please. My script doesn't seem to be working. I believe it to be the mysql query, that isnt encrypting the the password. Unfortunately I cant figure it out.Thanks

<?php include ("../../connect.php");  if ($_GET["self"] == "login") { if (!$_POST["username"] || !$_POST["pass"])  {  die("You need to provide a username and password.");  }          // Create query$q =   "SELECT * FROM alc_user"      ."WHERE username = \'{$_POST["username"]}\'"      ."AND pass= MD5('{$_POST["pass"]}')"      ."LIMIT 1"; // Run query $r = mysql_query($q); if ( $obj = @mysql_fetch_object($r) )  {  // Login good, create session variables  $_SESSION["valid_id"] = $obj->id;  $_SESSION["valid_user"] = $_POST["username"];  $_SESSION["valid_time"] = time();    // Redirect to member page  Header("Location: logged.php");  } else  {  // Login not successful check echo " {$_POST["username"]}"; echo " {$_POST["pass"]}" ;  }  } else { echo "<form action=\"?self=login\" method=\"post\">"; echo "Username: <input name=\"username\" size=\"15\"><br />"; echo "Password: <input type=\"password\" name=\"pass\" size=\"8\"><br />"; echo "<input type=\"submit\" value=\"login\">"; echo "</form>"; }?>

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...