Advertisement
Guest User

Untitled

a guest
Jun 12th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.07 KB | None | 0 0
  1. <?php
  2. include("blog/dbinformation.php");
  3. mysql_connect ($dbhost, $dbuser, $dbpass);
  4. mysql_select_db ($dbname);
  5. session_start();
  6. if (!isset($_SESSION['loggedIn'])) {
  7.     $_SESSION['loggedIn'] = false;
  8. }
  9. $num = 0;
  10. if (isset($_POST['username'])) {
  11.     $sql = mysql_query("SELECT * FROM users WHERE username='" . $_POST['username'] . "'");
  12.     while($row = mysql_fetch_array($sql)){
  13.         if (sha1($_POST['password']) == $row['password']) {
  14.                 $_SESSION['loggedIn'] = true;
  15.         } else {
  16.                 die ('Incorrect.');
  17.                 $num ++;
  18.         }
  19.     }
  20. }else{
  21.        
  22.     die ('Incorrect.');
  23.     $num ++;
  24.        
  25. }
  26. mysql_query("SELECT * FROM users WHERE username = '".$_POST['username']."' AND password = '".$_POST['password']."'");
  27. if ($num .= 0){ ?>
  28.  
  29. <html><head><title>Login</title></head>
  30.   <body>
  31.     <p>You need to login</p>
  32.     <form method="post">
  33.       Username: <input type="password" name="username"> <br />
  34.       Password: <input type="password" name="password"> <br />
  35.       <input type="submit" name="submit" value="Login">
  36.     </form>
  37.   </body>
  38. </html>
  39.  
  40. <?php
  41. }
  42. exit();
  43. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement