Advertisement
Guest User

Untitled

a guest
Jul 3rd, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.85 KB | None | 0 0
  1.  <?php
  2.  ob_start();
  3.   include("rmb.php");                                
  4.     $cxn = mysqli_connect($host,$user,$passmilah,$dbase)
  5.              or die("Query died: connect");              
  6.     $sql = "SELECT username FROM user
  7.              WHERE username='$_POST[fusername]'";
  8.     $result = mysqli_query($cxn,$sql)
  9.                 or die("Query died: fusername ");
  10.                 //.mysqli_error($cxn));
  11.     $num = mysqli_num_rows($result);                    
  12.     if($num > 0)  //login name was found                
  13.     {
  14.       $sql = "SELECT username FROM user
  15.              WHERE username='{$_POST['fusername']}'
  16.              AND password='".md5($_POST['fpassword'])."'";
  17.       $result2 = mysqli_query($cxn,$sql)
  18.                    or die(mysqli_error($cxn));      
  19.       $num2 = mysqli_num_rows($result2);                
  20.       if($num2 > 0)  //password matches                  
  21.       {  
  22.         $_SESSION['auth']="yes";                        
  23.         $_SESSION['logname'] = $_POST['fusername'];      
  24.         $sql = "INSERT INTO login (username,logintime)
  25.                 VALUES( '" . $_SESSION [ 'logname' ] . "', NOW() )";
  26.         $result = mysqli_query($cxn,$sql) or die(mysqli_error($cxn));      
  27.         header('Location: home.php');
  28.       }
  29.       else  // password does not match    
  30.         {
  31.         $message_1="The Login Name, '$_POST[fusername]'
  32.                exists, but you have not entered the
  33.                correct password! Please try again.";
  34.         $fusername = strip_tags(trim($_POST['fusername']));
  35.         include("home.php");
  36.       }                                                
  37.     }                                                  
  38.     else  // login name not found                    
  39.     {
  40.       $message_1 = "The User Name you entered does not
  41.                    exist! Please try again.";
  42.       include("home.php");
  43.     }
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement