Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.70 KB | None | 0 0
  1. <?php
  2. session_start();
  3. include ('connect.php');
  4.  
  5. if ($_POST['submit']){
  6.     //get data
  7.    
  8.  
  9.  
  10.     $username = $_POST['user'];
  11.     $password = $_POST['pass'];
  12.    
  13.     if ($username && $password) {
  14.                 $password = md5($password);
  15.         $query = mysql_query("SELECT * FROM users WHERE  user='$username' AND pass='$password'");
  16.    
  17.         while ($getrows = mysql_fetch_assoc($query)){
  18.        
  19.         $dbuser = $getrows['user'];
  20.         $dbpass = $getrows['pass'];
  21.        
  22.         }
  23.             if (($username == $dbuser) && ($password == $dbpass)) {
  24.            
  25.             $_SESSION['user'] = $username;
  26.             header("location:index.php");
  27.     } else {
  28.     echo "Login Failed";
  29.     }
  30. } else {
  31.     die("username and password fields should not be left empty");
  32. }
  33. }
  34.  
  35. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement