daily pastebin goal
85%
SHARE
TWEET

Untitled

a guest Jun 8th, 2017 79 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2.  
  3. if(isset($_POST['login'])) {
  4.  
  5.     // variablerna lagrar information från formuläret som används i MySQL-frågan
  6.     $username = mysql_real_escape_string(trim($_POST['userid']));
  7.     $password = mysql_real_escape_string(trim($_POST['user_pass']));
  8.  
  9.     if($USE_MD5){
  10.         $password = md5($password);
  11.     }
  12.    
  13.     // kontrollerar om användaruppgifterna finns i MySQL-tabellen
  14.     $query = mysql_query("SELECT * FROM `login` WHERE `userid` = '$username' AND `user_pass` = '$password' LIMIT 1") or die(mysql_error());
  15.     $row = mysql_fetch_array($query);
  16.    
  17.     // kontrollerar om användarkontot finns
  18.     if(mysql_num_rows($query) > 0) {
  19.  
  20.         $_SESSION['account_login'] = 'true';
  21.         $_SESSION['account_id'] = $row['account_id'];
  22.         $_SESSION['account_username'] = $username;     
  23.         $_SESSION['account_level'] = $row['level'];
  24.         $_SESSION['account_email'] = $row['email'];
  25.         echo "You successfully logged in...<br/><br/>";
  26.         echo ">><a href=\"index.php?p=settings\"> Press here to continue</a>";
  27.  
  28.     }
  29.     else {
  30.         echo "Failed to login...<br/><br/>";
  31.         echo ">><a href=\"index.php?p=login\"> Try again</a>";
  32.     }
  33. }
  34.  
  35. else {
  36.     echo "<h2>Login</h2>";
  37.     echo "<form action=\"\" method=\"post\">";
  38.     echo "<table border=\"0\">";
  39.     echo "<tr><td>Username</td><td><input name=\"username\" type=\"text\"/></td></tr>";
  40.     echo "<tr><td>Password</td><td><input name=\"password\" type=\"password\"/></td></tr>";
  41.     echo "<tr><td colspan=\"2\" ><input name=\"login\" type=\"submit\" id=\"login\" value=\"Login!\"/></td></tr>";
  42.     echo "</table>";
  43.     echo "</form>";
  44. }
  45.  
  46. ?>
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