Advertisement
Guest User

Untitled

a guest
Nov 25th, 2015
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. <?php
  2.  
  3. //check for required fields from the relevant table
  4. if ((!isset($_POST['username'])) || (!isset($_POST['member'])))
  5.  
  6. {
  7. exit;
  8. }
  9. //connecting to the mysql server and selecting the database. First is host, then username,
  10. //then password, then database name
  11. //erase the :7777 part after localhost if it is there, as that is only to get it working on my laptop
  12. $mysqli = mysqli_connect("localhost", "root", "", "assignment")
  13. or die(mysql_error());
  14.  
  15.  
  16.  
  17. //Have it get the names via the username and password that was entered
  18.  
  19. $sql = ("SELECT * FROM member WHERE username ='{$_POST['username']}'
  20. and password = '{$_POST['password']}' LIMIT 1");
  21.  
  22. $result = mysqli_query($mysqli, $sql)
  23. or die(mysqli_error($mysqli));
  24.  
  25. if (mysqli_num_rows($result) == 1)
  26. {
  27. while ($info = mysqli_fetch_array($result))
  28. {
  29. $f_name = stripslashes($info['f_name']);
  30. $l_name = stripslashes($info['l_name']);
  31. }
  32. //set authorization cookie
  33. setcookie("auth", "1", 0, "/", "yourdomain.com", 0);
  34. header("Refresh: 3; auth.php");
  35. echo "<p><a href='auth.php'>Wait for 3sec, or click here if you're not directed</a></p>";
  36. }
  37.  
  38. else
  39. {
  40. header("Refresh: 3; login.php");
  41. echo "<p><a href='login.php'>Wait for 3sec, or click here if you're not directed</a></p>";
  42. }
  43.  
  44. mysqli_close($mysqli);
  45.  
  46. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement