SHARE
TWEET

Untitled

a guest May 22nd, 2017 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.     session_start();
  3.     require 'mysql.php';
  4.     if ( isset($_POST['login']) && $_POST['username']!=' ' )
  5.     {
  6.         $usr = $_POST['username'];
  7.         $query = "SELECT * FROM users WHERE username='$usr'";
  8.         $result = mysql_query($query) or
  9.             die(mysql_error());
  10.         if ( $row = mysql_fetch_array($result) )
  11.         {
  12.             if ( $row['password'] == md5("asdf".md5($_POST['password'])) )
  13.             {
  14.                 $_SESSION['username']=$usr;
  15.                 $_SESSION['auth']=true;
  16.                 echo 'Redirecting to main page';
  17.             }
  18.             else
  19.                 echo 'Password does not match!';
  20.         }
  21.         else
  22.             echo 'User does not exist! <a href="newaccount.php">Create new account</a>';
  23.     }
  24. ?>
  25. <html>
  26. <head>
  27. <title>Login</title>
  28. </head>
  29. <body>
  30. <?php
  31.     if ( !isset($_SESSION['auth']) || $_SESSION['auth']=false )
  32.     {
  33.         echo '<form action="login.php" method="POST">';
  34.         echo 'Username: <input type="text" name="username" /><br />';
  35.         echo 'Password: <input type="password" name="password" /><br />';
  36.         echo '<input type="submit" name="login" value="Log in"></form>';
  37.     }
  38. ?>
  39. </body>
  40. </html>
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top