...

View Full Version : Wierd logging Page Problem



srule_
01-02-2008, 05:28 PM
Hello, I am making a loging page and I am getting an odd problem. The code below allows me to login for one user name I created but not the other!



// Check Inputed Data With Database
function checkWithDB($headerURL){
if (empty($this->errors)) { // If everything's OK.
/* Retrieve the user_id and username for
that email/password combination. */
$query = "SELECT * FROM members WHERE username='".$this->username."' AND password='".$this->password."'";
$result = @mysql_query ($query); // Run the query.
$row = mysql_fetch_array ($result); // Return a record, if applicable.

if ($row) { // A record was pulled from the database.

// Set the session data & redirect.
session_name ('YourVisitID');
session_start();
$_SESSION['user_id'] = $row[0];
$_SESSION['username'] = $row[1];
$_SESSION['agent'] = md5($_SERVER['HTTP_USER_AGENT']);
header("location:$headerURL");
exit(); // Quit the script.

} else { // No record matched the query.
$this->errors[] = 'The username and password entered do not match those on file.'; // Public message.
}

}
}


the forum:


<form action="login.php" method="post">
<p>Username: <input type="text" name="username" size="20" maxlength="40" /> </p>
<p>Password: <input type="password" name="password" size="20" maxlength="20" /></p>
<p><input type="submit" name="submit" value="Login" /></p>
<input type="hidden" name="submitted" value="TRUE" />
</form>


this set of details from my database work:
login:Neil
Password: secret

this set of details from my database gives me the error: "The email address and password entered do not match those on file":
login:NeilTest
Password: secret

Fumigator
01-02-2008, 05:42 PM
You're right that IS weerd!

srule_
01-02-2008, 05:55 PM
the only difference is the working user/pass combination was created about 1 month ago and the non working set was created today

arnyinc
01-02-2008, 07:22 PM
What troubleshooting have you done? Echo your $query after you create it. Does it get to that line? Does it print out the proper username and password? What happens when copy and paste that line and run it in your MySQL administration program?

srule_
01-03-2008, 03:00 PM
I echoed of the username/password and the right ones get displayed.

when I manual preform the query in phpMyAdmin it says there are no matches. I'm guessing there is something wrong with my registration script that is changing the passwords when I insert them. does that sound logical?

srule_
01-03-2008, 03:05 PM
ya that was the problem, I mis typed when on my password variable.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum