Advertisement
Guest User

Untitled

a guest
Apr 19th, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.24 KB | None | 0 0
  1. <?php
  2.     session_start();
  3.     include("connection.php");
  4.  
  5.     //Establishing connection with our database
  6.     $error = "";
  7.    
  8.     //Variable for storing our errors.
  9.     if(isset($_POST["submit"]))
  10.     {
  11.         $username=$_POST['u_email'];
  12.         $password=$_POST['u_password'];
  13.  
  14.         if(empty($username) || empty($password) { $error = "Both fields are required."; }
  15.         else
  16.         {
  17.             $password = md5($password);
  18.  
  19.             // To protect from SQL Injection
  20.             $sql = $db->prepare("SELECT u_id FROM user WHERE u_email = ? AND u_password = ?");
  21.             $sql->bind_param("ss", $username, $password);
  22.             $sql->execute();
  23.  
  24.             // Get the result from query that was executed
  25.             $sql->store_result();
  26.  
  27.             if($sql->num_rows > 0)
  28.             {
  29.                 // Found one or more rows with that matches both email and password/
  30.                 echo "I'm inside if";
  31.                 //$_SESSION["u_email"] = $username;
  32.                 //header("Location:homeexample.php");
  33.             }
  34.             else
  35.             {
  36.                 // Found none
  37.                 echo "No row found";
  38.                 //header("Location:index.php");
  39.             }
  40.         }
  41.     }
  42. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement