Sabab

sajid

Jan 31st, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.96 KB | None | 0 0
  1.  <?php
  2.  session_start();
  3.  include 'db_conn.php';
  4.  if(isset($_POST['submit'])) {
  5.  
  6.   if(isset($_POST['username'])) $username = $_POST['username'];
  7.   if(isset($_POST['email'])) $username = $_POST['email'];
  8.   if(isset($_POST['contact'])) $username = $_POST['contact'];
  9.   if(isset($_POST['password'])) $password = $_POST['password'];
  10.  
  11.   if(empty($username)) {
  12.     $msg = "প্রবেশের জন্য তথ্যপূরণ আবশ্যক";
  13.     header("Location:login.php?msg=$msg");
  14.   } else {
  15.  
  16.     if(empty($password)) {
  17.       $msg = "প্রবেশের জন্য গুপ্তমন্ত্র আবশ্যক";
  18.       header("Location:login.php?msg=$msg");
  19.     } else{
  20.  
  21.   $user = "SELECT * FROM user_info WHERE username = '$username' or email = '$username' or contact = '$username'";
  22.   $usercheck = $conn->query($user);
  23.  
  24.   $sqli = "SELECT * FROM user_info WHERE username = '$username' and password = '$password' and approval = '1' or email = '$username' or contact = '$username' ";
  25.   $result = $conn->query($sqli);
  26.  
  27.  
  28.  
  29.   if ($result->num_rows > 0)  {
  30.     // output data of each row
  31.  
  32.     // using loop we are getting following information
  33.     $user_id="";
  34.     $email="";
  35.     $username="";
  36.     while($row = $result->fetch_assoc()) {    
  37.           $user_id=$row["user_id"];
  38.           $email=$row["email"];
  39.           $username=$row["username"];    
  40.     }
  41.  
  42.  
  43.     $_SESSION['user_id'] = $user_id;
  44.     $_SESSION['email'] = $email;
  45.     $_SESSION['username'] = $username;
  46.     $_SESSION['flag'] = true;
  47.  
  48.     header("location: home.php");
  49.  
  50.   } else{    
  51.   if ($usercheck->num_rows > 0)  {
  52.     $msg = "তোমার গুপ্তমন্ত্রটি মিথ্যা, আবার চেষ্টা করো";
  53.     header("Location:login.php?msg=$msg");
  54.   } else {
  55.       $msg = "তোমার তথ্যসমূহ অবান্তর";
  56.       header("Location:login.php?msg=$msg");
  57.   }}}
  58.   $conn->close();
  59. }
  60.  
  61. }
  62. ?>
Add Comment
Please, Sign In to add comment