Advertisement
Guest User

Untitled

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