Guest User

Untitled

a guest
Dec 16th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.84 KB | None | 0 0
  1. <?php // login.php
  2. // This page lets people log in to the site.
  3. define('TITLE', 'Clermont County Disc Golf Club');
  4. require('templates/header.html');
  5. require_once('discgolf_fns.php');
  6. // Print some introductory text:
  7. print '<h2>Login Form</h2>
  8. <p align=center>Login to view member only secret meetups!</p>';
  9. ?><!DOCTYPE HTML>
  10. <html lang="en">
  11. <div id="wrapper">
  12. <?php
  13.  
  14. $conn = db_connect();
  15. $username = $_POST['username'];
  16. $passwd = $_POST['passwd'];
  17.  
  18. if($_SERVER['REQUEST_METHOD'] == 'POST') {
  19. if(!empty($_POST['username']) && (!empty($_POST['passwd']))){
  20.  
  21. if (mysqli_connect_errno()) {
  22. echo "Error: Could not connect to database. Please try again later.";
  23. exit;
  24. }
  25. $conn = db_connect();
  26. $query = "select * from user where username = '".$username."' and passwd = sha1('".$passwd."')";
  27.  
  28. $result = $conn->query($query);
  29. if ($result->num_rows > 0)
  30. {
  31. session_start();
  32. $_SESSION['username'] = $username;
  33. $_SESSION['loggedin'] = time();
  34. print "User found";
  35. $conn->close();
  36.  
  37. ob_end_clean();
  38. header('Location: welcome.php');
  39. exit();
  40.  
  41. }else{
  42. print '<p>The submitted username and password do not match. Go back and try again</p>';
  43.  
  44. }
  45.  
  46.  
  47. }else{
  48.  
  49. print '<p>Please make sure you enter both email and password. Go back and try again</p>';
  50. }
  51.  
  52.  
  53. }else{
  54. print '<form action="login.php" method="post" class="loginform">
  55. <p align=center><label for="username"> User Name: </label><input type="text" name="username" size"20"></p>
  56. <p align=center><label for="passwd"> Password: </label><input type="password" name="passwd" size"20"></p>
  57. <p align=center><input type="submit" name="submit" value="Log In!" class ="button--pill"></p>
  58. </form>';
  59.  
  60. }
  61. ?>
  62. </div>
  63. </html>
  64. <?php include('templates/footer.html'); ?>
Add Comment
Please, Sign In to add comment