Advertisement
Guest User

Untitled

a guest
Sep 13th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.61 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include 'header.php';
  4. include 'functions.php';
  5. ?>
  6.  
  7. <center>
  8. <table>
  9. <form method="POST" action="login.php">
  10. <tr>
  11. <td>Username : </td><td><input type="text" name="username"/></td>
  12. </tr>
  13. <tr>
  14. <br /> <td>Password :</td><td><input type="password" name="password"/></td>
  15. </tr>
  16. <tr>
  17. <td><input type="submit" name="submit" value="log in"/></td>
  18. </tr>
  19. </form>
  20. </table>
  21. </center>
  22. <?php
  23.  
  24.  
  25. if (isset($_POST['submit']))
  26. {
  27. // check
  28. $username = $_POST['username'];
  29. $password =$_POST['password'];
  30. $submit = $_POST['submit'];  
  31. connect();
  32.     if (isset($username) && isset($password))
  33.     {
  34.         $sql = "SELECT username,password FROM users WHERE username = '$username'" OR die(mysql_error());
  35.        $res = mysql_query($sql);
  36.        if ($res =mysql_query($sql))
  37.        {
  38.             if (mysql_num_rows($res) > 0)
  39.             {
  40.             $sql2 = "SELECT id FROM users WHERE username = $username AND password = sha1($password)";
  41.             $res2 = mysql_query($sql2);
  42.                 if (mysql_num_rows($res2) > 0)
  43.                 {
  44.                 $row = mysql_fetch_assoc($res2);
  45.                 $_SESSION['uid'] = $row['id'];
  46.                 echo "You have successfully logged in, $username .<br><br><a href=\"./index.php\">Click here to go to the forums.</a>";
  47.                 }
  48.                 else
  49.                 {
  50.                 die ("Username and password combination are incorrect!");
  51.                 }
  52.         }
  53.         }
  54.         else
  55.         {
  56.             die("User does not exist!");
  57.         }
  58.     }
  59.     else
  60.     {
  61.     die("Please fill in all fields!");
  62.     }
  63. }
  64.  
  65. ?>
  66.  
  67. <?php
  68. include ('footer.php');
  69. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement