Advertisement
ammarafdhal

login 1

Oct 13th, 2019
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.33 KB | None | 0 0
  1. <?php
  2. $host = "localhost";
  3. $user = "root";
  4. $pwd  = "";
  5. $db   = "fypforum";
  6.  
  7. $con = ($GLOBALS["___mysqli_ston"] = mysqli_connect($host, $user, $pwd)) or die("Could not connect");
  8. mysqli_select_db($con, $db) or die("No database");
  9.  
  10. ?>
  11.  
  12. <?php
  13.  
  14.     session_start();
  15.    
  16.     include '../functions/db.php';
  17.  
  18.     $username = $_POST['username'];
  19.     $password = $_POST['password'];
  20.     $pwd = md5($password);
  21.  
  22.     $username = mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $_POST['username']);
  23.     $password = mysqli_real_escape_string($GLOBALS["___mysqli_ston"], $_POST['password']);
  24.  
  25.     $query = "SELECT * FROM tblaccount WHERE username = '$username' AND password = '$pwd'";
  26.     $result = mysqli_query($GLOBALS["___mysqli_ston"], $query) or die ("Verification error");
  27.     $array = mysqli_fetch_array($result);
  28.    
  29.     if ($array['username'] == $username){
  30.         $_SESSION['username'] = $username;
  31.         $_SESSION['fname'] = $array['fname'];
  32.         $_SESSION['lname'] = $array['lname'];
  33.         $_SESSION['user_Id'] = $array['user_Id'];
  34.         header("Location: list.php");
  35.     }
  36.    
  37.     else{
  38.         echo '<script language="javascript">';
  39.         echo 'alert("Incorrect username or password")';
  40.         echo '</script>';
  41.         echo '<meta http-equiv="refresh" content="0;url=../index.php" />';
  42.     }
  43.    
  44. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement