daily pastebin goal
94%
SHARE
TWEET

Untitled

a guest Jul 21st, 2017 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. require('db.php');
  3. session_start();
  4.  
  5. // If form submitted, insert values into the database.
  6. if (isset($_POST['username'])){
  7.     // removes backslashes
  8.     $username = stripslashes($_REQUEST['username']);
  9.     //escapes special characters in a string
  10.     $username = mysqli_real_escape_string($con,$username);
  11.     $password = stripslashes($_REQUEST['password']);
  12.     $password = mysqli_real_escape_string($con,$password);
  13.     //Checking is user existing in the database or not
  14.     $query = "SELECT * FROM `users` WHERE username='$username' and password='".md5($password)."'";
  15.     $result = mysqli_query($con,$query) or die(mysql_error());
  16.     $rows = mysqli_num_rows($result);
  17.     if($rows==1){
  18.         //This one works
  19.         $_SESSION['username'] = $username;
  20.  
  21.         //This one doesn't
  22.         $_SESSION['email'] = $rows ['email'];
  23.  
  24.         // Redirect user to index.php
  25.         header("Location: index.php");
  26.     }else{
  27.         echo "<div class='form'>
  28.         <p>Username/password is incorrect.</p>
  29.         <br/>Click here to <a href='login.php'>Login</a></div>";
  30.     }
  31. }else{
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top