SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member Whatever5476's Avatar
    Join Date
    Jun 2001
    Location
    Toronto
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Invalid password page with PHP and MySQL

    I'm trying to create a web-master login page. To connect to MySQL the web-master (which is myself) will have to enter the ID and password to login.

    e.g.User: Whatever5476, Password: **********

    How do i display the error page if i entered an invalid id/password or anyone who tried to guess my id and password?

    e.g. User: Whtver5476, Password: *****
    Enjoy Life...

  2. #2
    SitePoint Enthusiast drisley's Avatar
    Join Date
    Jun 2001
    Location
    Florida
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just have the login script query the database for the password and compare it to the one they typed in. If it is no correct, echo an error to the screen.

    What language are you using? I'm not sure if I'm understanding your question very well.
    David Risley
    Web Developer, Web Publisher, Blogger, Tech Dude
    PC Mechanic | WebbyOnline

  3. #3
    SitePoint Member Whatever5476's Avatar
    Join Date
    Jun 2001
    Location
    Toronto
    Posts
    10
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I'm sorry that i haven't made this clear enough.

    This is what i have (in php4) where $u and $p are parsed through HTML form with post method:

    //Code starts here...
    function this_error($errno, $error)
    {
    printf("%d: %s", $errno, $error);
    }

    $db="DB5476";
    $connection=mysql_connect("localhost", $u, $p)
    or die("Either the user does not exist or the password is incorrect...<br>\nPlease try again...<br>\n");
    mysql_select_db($db, $connection)
    or die(this_error(12345, "cannot connect..."));

    //Code ends here...

    so if i entered a non-existing id without password, it will tell me "12345, cannot connect..."

    once i put in an existing id or something in the password field, it will give me a warning message like this:

    Warning: MySQL Connection Failed: Access denied for user: 'Whatever5476@localhost' (Using password: NO) in /home/snowfox/www/public_html/php/edit.php on line 73
    Either the user does not exist or the password is incorrect...
    Please try again...

    shouldn't i get only my custom message telling me to try again without php's own warning message?

    how do i fix this problem and display the error message correctly?

    tia
    Enjoy Life...

  4. #4
    Victory shall be mine tubedogg's Avatar
    Join Date
    Mar 2001
    Location
    Medina, OH
    Posts
    440
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I believe adding @ in front of a function will turn off its' standard error reporting. Such as
    $connection = @mysql_connect('localhost',$u,$p) or die("error message blah");
    Kevin


Bookmarks

Posting Permissions

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