Advertisement
Guest User

Untitled

a guest
Aug 2nd, 2017
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. if (isset($_POST['login'])) {
  2. // Kollar om username och password matchar
  3. $username = mysql_real_escape_string($_POST['username']) ;
  4. $password = md5($_POST['password'] . $passwordsalt);
  5. $querypasswordmatch = mysql_query("SELECT password FROM people WHERE username = '$username'");
  6. if (!$querypasswordmatch) {
  7. die('Could not run query, $querypasswordmatch: ' . mysql_error());
  8. }
  9. $passwordmatch = mysql_fetch_row($querypasswordmatch);
  10. // Om dom matchar sätts inloggningskakorna och redirectas till början av index.php som inloggad och rätt meny visas
  11. if ($password == $passwordmatch[0]) {
  12. setcookie('login', md5($_POST['username'] . $usersalt));
  13. setcookie('username', $_POST['username']);
  14. if ($_GET['pID'] == '') {
  15. $pID = index;
  16. } else {
  17. $pID = $_GET['pID'];$username = mysql_real_escape_string($_POST['username']) ;
  18. $password = md5($_POST['password'] . $passwordsalt);
  19. $querypasswordmatch = mysql_query("SELECT password FROM people WHERE username = '$username'");
  20. if (!$querypasswordmatch) {
  21. die('Could not run query, $querypasswordmatch: ' . mysql_error());
  22. }
  23. $passwordmatch = mysql_fetch_row($querypasswordmatch);
  24. // Om dom matchar sätts inloggningskakorna och redirectas till början av index.php som inloggad och rätt meny visas
  25. if ($password == $passwordmatch[0]) {
  26. setcookie('login', md5($_POST['username'] . $usersalt));
  27. setcookie('username', $_POST['username']);
  28. if ($_GET['pID'] == '') {
  29. $pID = index;
  30. } else {
  31. }
  32. header('Location:index.php?pID=' . $pID);
  33. } else if (($_SERVER['REQUEST_METHOD'] == 'POST') && ($_POST['login'])) {
  34. echo '<div style="font-size:small; color:red"><br/>Felaktigt Användarnamn<br/> eller lösen</div></div>';
  35. }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement