Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.10 KB | None | 0 0
  1. include("loginclass.php";
  2. $sessionclass = new sessions();
  3. session_set_save_handler(array(&$sessionclass, 'open'),
  4. array(&$sessionclass, 'close'),
  5. array(&$sessionclass, 'read'),
  6. array(&$sessionclass, 'write'),
  7. array(&$sessionclass, 'destroy'),
  8. array(&$sessionclass, 'gc'));
  9. session_start()
  10.  
  11.  
  12.   $user = $_POST['user']; //pulls the username from the form
  13.   $pw = $_POST['pass']; //pulls the pass from the form
  14.   $pass = md5($pw); //makes our password an md5
  15.   mysql_connect("localhost", "sunyon", "pass") or die("Could not connect to MySQL server!");
  16.   mysql_select_db("sunyon_database") or die("Could not find MySQL database");
  17.   $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
  18.   if(!mysql_num_rows($login)) //if the username and pass are wrong
  19.   {
  20.         header("Location: login.php");  //redirects to our login page
  21.         die(); //stops the page from going any further
  22.   }
  23.   else
  24.   {
  25.         $_SESSION['username'] = $user;
  26.     header("Location: controlpanel.php");
  27.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement