SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Red face Login script works for only one user

    I have been working on this logon script, which has been encrypted. I have 5 users in the table, all passwords encrypted. I can only logon with 1 user successfully.

    PHP Code:
    <?php
    //  Author Y Symons
    //Start a session
    session_start();
    if(isset(
    $_POST['User']) && isset($_POST['Password']))
    {
    //Delcarle the variables.
    $User=$_POST['User'];
    //$passwd=($_GET['Password']);
    $passwd=md5($_POST['Password']);
    //connect to the database
      
    include ("connect.php");
    //query database to match username and password
    $query "select * from users where User='$User' and password_md5='$passwd'";
       
    $result=mysql_query($query) or die ("error in query");

        if (
    mysql_num_rows($result)>0)
        {
          
    $_SESSION['valid_user']=$User;
        }
        
    mysql_close();
    }
    ?>
    <html>
    <body>
    <?php
    //checking to see if the user is a valid user
      
    if (isset($_SESSION['valid_user']))
      {
        echo 
    "<p align='center'>You are logged in as ".$_SESSION['valid_user']."</p>";
        echo 
    "<p align='center'><a href='system_management.php'>System Management</a></p>";
        echo 
    "<p align='center'><a href='logout.php'>Log Out</a></p>";
      }
      else
      {
       echo 
    "<p align='center'> Please enter Username and Password</p><br>";
      }
      echo 
    "<h3 align='center'>Please Logon</h3>";
      
    //form displayed for logging on
      
    echo "<form action=''adminlogin.php' method='GET'>";
      echo 
    "<table align='center' border='1'>";
      echo 
    "<tr><th>UserID</th><td><input type='text' name='User'></td></tr>";
      echo 
    "<tr><th>Password</th><td><input type='password' name='Password'></td></tr><tr><td colspan=2 align='center'><input type='submit' value='login'></td></tr>";
      echo 
    "</table>";
     echo 
    " </form>";
    ?>
    </body>
    </html>
    Anything anyone can tell me would be really appreciated

    Vonz

  2. #2
    Obey the Purebreed trib4lmaniac's Avatar
    Join Date
    Dec 2004
    Location
    Cornwall, UK
    Posts
    594
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure you're typing in the passwords correctly? Try resetting them and entering some new one.

  3. #3
    SitePoint Wizard cmuench's Avatar
    Join Date
    Jul 2005
    Location
    At my computer
    Posts
    2,251
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    also the username might be messed up.

  4. #4
    SitePoint Enthusiast
    Join Date
    Dec 2005
    Posts
    88
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you all. Sorry a bit of a panic. One minute it was working then it wasn't. Must have done something to the passwords when I encrypted them.

    I look forward to the day that I feel confident about coding.

    Many thanks again

    Vonz


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
  •