Advertisement
Guest User

log in page

a guest
Aug 14th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.79 KB | None | 0 0
  1. <?php
  2. $error=''; //Variable to Store error message;
  3. if(isset($_POST['submit'])){
  4.  if(empty($_POST['user']) || empty($_POST['pass'])){
  5.  $error = "Username or Password is Invalid";
  6.  }
  7.  else
  8.  {
  9.  //Define $user and $pass
  10.  $user=$_POST['user'];
  11.  $pass=$_POST['pass'];
  12.  // Connection with serverr
  13.  $conn = mysqli_connect("localhost", "root", "");
  14.  //Select Database
  15.  $db = mysqli_select_db($conn, "test");
  16.  //sinformation of registerd user and finds user match.
  17.  $query = mysqli_query($conn, "SELECT * FROM userpass WHERE pass='$pass' AND user='$user'");
  18.  
  19.  $rows = mysqli_num_rows($query);
  20.  if($rows == 1){
  21.  header("Location: find.php"); // Redirecting to other page
  22.  }
  23.  else
  24.  {
  25.  $error = "Username of Password is Invalid";
  26.  }
  27.  mysqli_close($conn); // Closing connection
  28.  }
  29. }
  30.  
  31. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement