View Full Version : Wierd logging Page Problem

01-02-2008, 06: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['user_id'] = $row[0];
$_SESSION['username'] = $row[1];
$_SESSION['agent'] = md5($_SERVER['HTTP_USER_AGENT']);
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" />

this set of details from my database work:
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":
Password: secret

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

01-02-2008, 06: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

01-02-2008, 08: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?

01-03-2008, 04: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?

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