Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jul 2007
    Posts
    571
    Thanks
    25
    Thanked 28 Times in 28 Posts

    Wierd logging Page Problem

    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!

    PHP Code:
    // 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:
    Code:
    				<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

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You're right that IS weerd!

  • #3
    Regular Coder
    Join Date
    Jul 2007
    Posts
    571
    Thanks
    25
    Thanked 28 Times in 28 Posts
    the only difference is the working user/pass combination was created about 1 month ago and the non working set was created today

  • #4
    Regular Coder
    Join Date
    Jan 2003
    Posts
    867
    Thanks
    4
    Thanked 8 Times in 8 Posts
    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?

  • #5
    Regular Coder
    Join Date
    Jul 2007
    Posts
    571
    Thanks
    25
    Thanked 28 Times in 28 Posts
    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?

  • #6
    Regular Coder
    Join Date
    Jul 2007
    Posts
    571
    Thanks
    25
    Thanked 28 Times in 28 Posts
    ya that was the problem, I mis typed when on my password variable.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •