Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.75 KB | None | 0 0
  1. <?php
  2.  
  3.     session_start();
  4.  
  5.     //Connect to database.
  6.     include("connect.php");
  7.  
  8.     $email = $_POST["input_email"];
  9.     $password = $_POST["input_password"];
  10.  
  11.     //Query the database for login details.
  12.     $query = "SELECT * FROM CSC2043_users WHERE email='$email' AND password='$password'";
  13.  
  14.     $verify = mysqli_query($conn, $query) or die(myqli_error($conn));
  15.  
  16.     //Disconnect from database.
  17.     mysqli_close($conn);
  18.  
  19.     //If there is a match in the database.
  20.     if(mysqli_num_rows($verify) > 0) {
  21.  
  22.         //Create a session for the user.
  23.         $_SESSION['user'] = $email;
  24.         header("Location: profile.php");
  25.     } else {
  26.  
  27.         //Invalid input. Enter details again.
  28.         header("Location: login.php");
  29.     }  
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement