SitePoint Sponsor

User Tag List

Results 1 to 10 of 10

Thread: Password script

  1. #1
    SitePoint Zealot
    Join Date
    Dec 2001
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Password script

    Could anyone tell me what's wrong with this password script? thnx

    PHP Code:
    <form>
    <input type="text" name="username">
    <input type="text" name="password">
    <input type="submit" name="submit" value="submit">
    </form>

    ...server settings...

    <?php
                
                
    if ("$submit == submit") {
                
                
    $sql = @mysql_query("SELECT username, password FROM admin_login WHERE username='$username' AND password='$password'");
                   if (!
    $sql) { exit("Error fetching variables"); }
                               
                if (
    $username == username && $password == password) {
                echo (
    "Authorised ! Click to proceed"); }
                
                else { echo(
    "You are not authorised"); }
                
                }
                
                
                
    ?>
    url: http://www.infraredesign.com/Clubrac...dmin_login.php

  2. #2
    purple monkey dishwasher scoates's Avatar
    Join Date
    Nov 2001
    Location
    Montreal
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    if ($submit == "submit") { 
    There's a tutorial on conditionals here:
    http://www.rci.rutgers.edu/~jfulton/...ditionals.html

    S

  3. #3
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I was about to post and Sean beat me to it...

    Sketch
    Last edited by Sketch; Feb 13, 2002 at 12:40.
    Aaron Brazell
    Technosailor



  4. #4
    purple monkey dishwasher scoates's Avatar
    Join Date
    Nov 2001
    Location
    Montreal
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It's Sean. (-:

    The second conditional is screwed up, too. You're not getting the proper values from mySQL.

    S

  5. #5
    SitePoint Zealot
    Join Date
    Dec 2001
    Posts
    115
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    doh..i knew that one
    the login doesn't work yet though...keep getting not authorised while the password and username are correct.

  6. #6
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally posted by scoates
    It's Sean. (-:

    The second conditional is screwed up, too. You're not getting the proper values from mySQL.

    S
    uh....yeah...thats what I said...

    Sketch
    Aaron Brazell
    Technosailor



  7. #7
    purple monkey dishwasher scoates's Avatar
    Join Date
    Nov 2001
    Location
    Montreal
    Posts
    794
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Smith? Winston Smith, is that you?

    S

  8. #8
    SitePoint Addict eddiembabaali's Avatar
    Join Date
    Mar 2001
    Location
    USA, Philadelphia
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try this

    PHP Code:
    <?php
                
                
    if ($submit == "submit") {
                
                
    $sql = @mysql_query("SELECT username, password FROM admin_login WHERE username='$username' AND password='$password'");
                   if (!
    $sql) { exit("Error fetching variables"); }
                               
                if ((
    username == "$username") && (password == "$password")) {
                echo (
    "Authorised ! Click to proceed"); }
                
                else { echo(
    "You are not authorised"); }
                
                }
                
                
                
    ?>
    Good luck !
    Last edited by eddiembabaali; Feb 14, 2002 at 14:44.
    cd pub \r; more beer

    Eddie

  9. #9
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if ("$submit == "submit")

    This won't work. Uneven quotes. REmove the one from before $submit



    Sketch
    Aaron Brazell
    Technosailor



  10. #10
    SitePoint Addict eddiembabaali's Avatar
    Join Date
    Mar 2001
    Location
    USA, Philadelphia
    Posts
    206
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ooops sorry typo thanks sketch !!
    cd pub \r; more beer

    Eddie


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
  •