noordean

login.php

Sep 29th, 2016
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.54 KB | None | 0 0
  1. <?php
  2. session_start();
  3. require_once('class.php');
  4. if (isset($_POST['submit'])){
  5.     if (empty($_POST['username']) || empty($_POST['password'])){
  6.         echo "<p style='color:red'>Fill both fields</p>";
  7.     }
  8.     else{
  9.         $user = new User();
  10.         $username = $user->escapeInput($_POST['username']);
  11.         $password = sha1($user->escapeInput($_POST['password']));
  12.         if ($user->authenticate($username,$password)){
  13.             $_SESSION['user'] = $username;
  14.             header("Location:homepage.php");
  15.         }
  16.         else{
  17.             echo "<p style='color:red'>Incorrect login details</p>";
  18.         }
  19.     }
  20. }
Add Comment
Please, Sign In to add comment