IPB
Your Ad Here


Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
Login via MySQL denies access
Misha Singh
post 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);
?>
Go to the top of the page
 
+Quote Post

Reply to this topicStart new topic
Tags
No Tag inserted yet

1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 



RSS Lo-Fi Version Time is now: 21st November 2009 - 11:53 AM
Your Ad Here