daily pastebin goal
62%
SHARE
TWEET

Untitled

a guest Jun 18th, 2017 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. $act = $_GET['act']; //retrives the page action
  3. if(empty($act)) //if there is no action
  4. {
  5.   echo('<form action="login.php?act=auth" method="post" name="loginform" id="loginform">
  6.   <p>Username
  7.   <input type="text" name="user">
  8.   </p>
  9.   <p>Password
  10.   <input type="password" name="pass">
  11.   </p>
  12.   <p>
  13.   <input type="submit" name="Submit" value="Login">
  14.   </p>
  15.   </form>');
  16. }
  17. elseif($act == "auth") //if our page action = auth
  18. {
  19.   $user = $_POST['user']; //pulls the username from the form
  20.   $pw = $_POST['pass']; //pulls the pass from the form
  21.   $pass = md5($pw); //makes our password an md5
  22.   include("connect.php"); //connects to our mysql database
  23.   $login = mysql_query("SELECT * FROM `users` WHERE `user` = '$user' AND `pass` = '$pass'"); //selects info from our table if the row has the same user and pass that our form does
  24.   if(!mysql_num_rows($login)) //if the username and pass are wrong
  25.   {
  26.     header("Location: login.php");  //redirects to our login page
  27.     die(); //stops the page from going any further
  28.   }
  29.   else
  30.   {
  31.     setcookie("user", $user, time()+3600);//sets our user cookie
  32.         setcookie("pass", $pass, time()+3600);//sets our pass cookie
  33.         header("Location: modclient.php");//instead of yourpage.php it would be your protected page
  34.   }
  35. }
  36. ?>
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