Advertisement
DigitalAurora

PHP Login function

Nov 26th, 2015
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.49 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4.  
  5. $loginUsr = ('usernamehere'); /* Username for the page */
  6. $loginPswd = ('passwordhere'); /* Password for the page */
  7.  
  8. $username = ($_POST['username']); /* Name of usernamefield on login page */
  9. $password = ($_POST['password']); /* Name of password field on login page */
  10.  
  11. if ($username == $loginUsr && $password == $loginPswd) {
  12.     $_SESSION['loggedin'] = 'true';
  13.     header("Location: admin.php");
  14.     exit();
  15. } else {
  16.     echo('Login failed');
  17.     session_destroy();
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement