Login via MySQL denies access |
![]() ![]() |
Login via MySQL denies access |
Jul 3 2009, 10:24 AM
Post
#1
|
|
|
Advanced Member ![]() ![]() ![]() Group: Members Posts: 7,881 Joined: 23-November 08 Member No.: 6,521 |
The login script below appears to connect successfully with the database, but produces the "Access Denied: Are you really you?" message, even though I have put the user details in the relevant table.
I would really appreciate suggestions about where this is going wrong. (None of the site pages have coding that restricts access yet. Could this be the problem?) Code: <?php include ('../config.php'); /* get the incoming ID and password hash */ $user = $_POST["yourusername"]; $pass = sha1($_POST["youruserpass"]); /* establish a connection with the database */ $server = mysql_connect("$dBaseServer", "$dBaseUser", "$dBasePass"); if (!$server) die(mysql_error()); mysql_select_db("$dBaseName"); /* SQL statement to query the database */ $query = "SELECT * FROM tablename WHERE username = '$user' AND userpass = '$pass'"; /* query the database */ $result = mysql_query($query); /* Allow access if a matching record was found, else deny access. */ if (mysql_fetch_row($result)) echo "Access Granted: Welcome, $user!"; else echo "Access Denied: Are you really you?"; mysql_close($server); ?> |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 21st November 2009 - 11:53 AM |