SHARE
TWEET

Untitled

a guest Jun 7th, 2017 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #logger en person ind
  2. if(isset($_POST['login'])) {
  3.    
  4.         $username = $_POST['username'];
  5.         $password = sha1($_POST['password']);
  6.    
  7.         $mysql = connect();
  8.         $sql = "SELECT id,username,password,fornavn,efternavn,level,dag FROM users WHERE username = ? AND password = ? LIMIT 1";
  9.         $stmt = $mysql->prepare($sql);
  10.         $stmt->bind_param("ss", $username, $password);
  11.         $stmt->execute();
  12.         $stmt->store_result();
  13.  
  14.         if( $stmt->num_rows == 0)
  15.         {
  16.             #echo "Brugernavn eller er kodeord forkert";
  17.         }
  18.         else
  19.         {
  20.            
  21.             $stmt->bind_result($id,$username,$password,$fornavn,$efternavn,$level,$dag);
  22.             $stmt->fetch();
  23.             $stmt = $mysql->prepare("UPDATE users SET online = '1', login_time = 'login_time' WHERE username = '$username'") or die($mysql->error);
  24.             $stmt->execute();
  25.            
  26.            
  27.             #System til point
  28.             $dagTjek = date('z');
  29.             if($dag != $dagTjek)
  30.             {
  31.                 $mysql = connect();
  32.                 $stmt = $mysql->prepare("UPDATE users SET point = '$point+10', dag='$dagTjek' WHERE username = '$username'") or die($mysql->error);
  33.                 $stmt->execute();
  34.             }
  35.  
  36.             $_SESSION['username']   = $username;
  37.             $_SESSION['userid']     = $id;
  38.             $_SESSION['fornavn']    = $fornavn;
  39.             $_SESSION['brugerid']   = $id;
  40.             $_SESSION['efternavn']  = $efternavn;
  41.             $_SESSION['level']      = $level;
  42.             $_SESSION['loggetind']  = true;
  43.             #$_SESSION['timestamp'] = time();
  44.             $sti = $_SERVER['SCRIPT_NAME']; // Finder URL'en til header location
  45.             header("location: ".$sti ."");
  46.            
  47.         }#Lukker else
  48. }#Lukker isset login
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