daily pastebin goal
23%
SHARE
TWEET

Untitled

a guest Sep 22nd, 2016 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php session_start();
  2. include_once "connect_to_mysql.php";
  3. if (isset($_POST['username'])) {
  4. $username = stripslashes($_POST['username']);
  5. $username = strip_tags($username);
  6. $username = mysql_real_escape_string($username);
  7. $password = $_POST['password'];
  8. if ((!$username) || (!$password)) {
  9. $errorMsg = 'Please fill in both fields';
  10. } else {
  11. $sql = mysql_query("SELECT * FROM members WHERE username='$username' AND password='$password' AND emailactivated='1'");
  12. $login_check = mysql_num_rows($sql);
  13. if($login_check > 0){
  14. while($row = mysql_fetch_array($sql)){
  15.  
  16.     $id = $row["id"];  
  17.     session_register('id');
  18.     $_SESSION['id'] = $id;
  19.  
  20.     $username = $row["username"];  
  21.     session_register('username');
  22.     $_SESSION['username'] = $username;
  23.  
  24.     mysql_query("UPDATE members SET lastlogin=now() WHERE id='$id'");
  25.  
  26.     header("location: welcome.php?id=$id");
  27.     exit();
  28. }
  29. } else {
  30.         $errorMsg = "Incorrect login data, try again";
  31.     }
  32. }
  33. }
  34. ?>
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