Advertisement
Guest User

Untitled

a guest
May 27th, 2017
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.00 KB | None | 0 0
  1. <?php
  2. include "../includes/config.php";
  3. if(!isset($_COOKIE['admin'])){
  4.     if(isset($_POST['submitted'])){
  5.         $user = mysql_real_escape_string(stripslashes($_POST['user']));
  6.         $pass = md5($_POST['pass']);
  7.         $query = mysql_query("SELECT * FROM `users` WHERE `user` = '".$user."' AND `pass` = '".$pass."'") or die(mysql_error());
  8.         if ($query) {
  9.             $cookie = setcookie("admin", $user.$pass, time()+31556926, "/");
  10.             echo "Login successful.";
  11.             if($cookie) {
  12.                 echo "The cookie was set.<br />";
  13.             } else {
  14.                 echo "The cookie was not set.";
  15.             }
  16.         } else {
  17.             echo "There was an error when you tried to login. Please don't refresh the page. This may just be a fluke.";
  18.         }
  19.     } else {
  20.         echo "<form action='' method='post'>
  21.         Username: <input type='text' name='user' /><br />
  22.         Password: <input type='password' name='pass' /><br />
  23.         <input type='submit' name='login' value='Login' />
  24.         <input type='hidden' name='submitted' value='true' />";
  25.     }
  26. } else {
  27.     echo "You're already logged in.";
  28. }
  29. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement