Guest User

wdwqdwqdq

a guest
Oct 13th, 2016
29
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. <?php
  2. session_start();
  3. //connect to the database
  4. include('connect.php');
  5. //get details from html form
  6. $username = $_POST['username'];
  7. $password = $_POST['password'];
  8.  
  9.  
  10.  
  11. //login to database
  12. $sql = "SELECT * FROM register WHERE username = '$username' and password = '$password'"; // select all products from the database
  13. $result = mysqli_query($conn,$sql); // run the query and store in an array $result
  14. $found = 0;
  15. while ($row = mysqli_fetch_array($result))
  16. {
  17. $found = 1;
  18. $username = $row[1];
  19. $password = $row[2];
  20. $usertype = $row[8];
  21. $email = $row[5];
  22. $_SESSION['email'] = $email;
  23. if
  24. ($usertype == 1)
  25. {
  26. echo "<p>Successfully Logged in!</p>";
  27. echo "<p>Admin granted</p>";
  28. echo "<a href='control.html'> Click here To Return</a>";
  29.  
  30.  
  31. }
  32. else
  33.  
  34. {
  35. echo "<p>Logged in!</p>";
  36. echo "<a href='control.html'> Click here To Return</a>";
  37. }
  38. }
  39.  
  40. if ($found==0)
  41. {
  42.  
  43. echo "Invalid Login, Please return and try again, if the problem continues, please contact support.";
  44. }
  45. $conn->close();
  46.  
  47. ?>
Add Comment
Please, Sign In to add comment