Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.94 KB | None | 0 0
  1. <?php
  2.     $host = "localhost";
  3.     $user = "root";
  4.     $pass = "pass";
  5.     $db = "sheetpal";
  6.    
  7.     mysql_connect($host, $user, $pass) or die("Could not connect to database");
  8.     mysql_select_db($db);
  9.    
  10.     if (isset($_POST['username'])){
  11.         $username = $_POST['username'];
  12.         $password = $_POST['password'];
  13.        
  14.         $username = stripslashes($username);
  15.         $password = stripcslashes($password);
  16.        
  17.         $sql = "SELECT * FROM users WHERE username = '$username' and password = '$password' ";
  18.         $res = mysql_query($sql);
  19.         if(mysql_num_rows($res) == 1){
  20.             echo "You have successfulyl logged in.";
  21.             exit();
  22.         }
  23.         else {
  24.             echo"Invalid login information.";
  25.             exit();
  26.         }
  27.     }
  28. ?>
  29.  
  30. <html>
  31. <body>
  32.     <form method="post" action="index.php">
  33.     Username: <input type = "text" name = "username" /><br /><br />
  34.     Password : <input type = "password" name = "password" /><br /><br />
  35.     <input type = "submit" name = "submit" value = "Log in" />
  36.     </form>
  37. </body>
  38. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement