Advertisement
Guest User

Untitled

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