SHARE
TWEET

Untitled

a guest May 31st, 2017 57 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php include('includes/header.php');?>
  2. <?php
  3.     require_once('includes/mysqli_connect.php');
  4.     if(isset($_POST['login']))
  5.     {
  6.         $username = $_POST['txtUsername'];
  7.         $password = $_POST['txtPassword'];
  8.         $query = "select * from accounts where (userName = '$username' and userPassword = SHA('$password'))";
  9.         $result = mysqli_query($dbc, $query);
  10.         $num = mysqli_num_rows($result);
  11.  
  12.         $row = mysqli_fetch_array($result, MYSQLI_ASSOC);
  13.         $_SESSION['user_name'] = $row['userName'];
  14.         $name = $row['userName'];
  15.         setcookie('recordsmember', $name, time()+60*60*2);
  16.  
  17.         if($num > 0)
  18.         {
  19.             header('Location: home.php');
  20.         }
  21.         else
  22.         {
  23.             echo "Unknown user or incorrect password!";
  24.         }
  25.     }
  26. ?>
  27. <h1>login</h1>
  28. <form action="login.php" method="post">
  29.     <fieldset>
  30.         <input type="text" name="txtUsername" placeholder="enter a username"/><br/>
  31.         <input type="password" name="txtPassword" placeholder="enter a password"/><br/>
  32.         <input type="submit" name="login" value="login"/>
  33.     </fieldset>
  34. </form>
  35. <?php include('includes/footer.html');?>
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