Advertisement
Guest User

Untitled

a guest
Mar 6th, 2018
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.54 KB | None | 0 0
  1. <!DOCTYPE html>
  2. <html id= "movie-color">
  3. <head>
  4. <title> Movie Xpress </title>
  5. <link rel="stylesheet" type="text/css" href="../css/site.css">
  6. </head>
  7. <body>
  8. <h3><a href="../index.html">ePortfolio</a></h3>
  9. <center>
  10. <h2 id="movie-title"> myMovies Xpress! </h2>
  11. <h4 id="login-direct"> Welcome to myMoviesXpress! <br>Please type in your login credentials in order to access the movie database.</h4>
  12. <hr>
  13. </center>
  14. <div class="row" style="padding-top: 25px;">
  15. <form action="logon.php" method="POST" id=movieForm>
  16. <label name="username-input">
  17. <font class=movie-username>Username: </font>
  18. </label>
  19. <input type="text" id="username-input" class="movie-login" name="username-input">
  20. <br>
  21. <br>
  22. <label name="password-input">
  23. <font class=movie-username>Password: </font>
  24. </label>
  25. <input type="password" id="password-input" class="movie-login" name="user-input">
  26. <br>
  27. <div class="row" style="padding-top: 15px;">
  28. <button type="submit" value="Submit">Login</button>
  29. <button type="reset" value="Reset">Clear</button>
  30. </div>
  31. </form>
  32. </div>
  33. <script src="script.js"></script>
  34. </body>
  35. </html>
  36.  
  37. <?php
  38. session_start();
  39.  
  40. if(empty($_POST['username-input'])){
  41. $this->HandleError("UserName is empty!");
  42. return false;
  43. }
  44. if(empty($_POST['password-input'])){
  45. $this->HandleError("Password is empty!");
  46. return false;
  47. }
  48. $filepath = 'data/credentials';
  49. $fp = fopen($filepath, 'r');
  50.  
  51. $username = $_POST['username-input'];
  52. $password = $_POST['password-input'];
  53.  
  54. if($username != ""){
  55. if($password != ""){
  56. $loginCredentials = $username." ".$password;
  57. while($line = fgets($fp)){
  58. $dbLoginCredentials = strtok($line, ':');
  59. $dbDisplayName = strtok(':',' ');
  60. if($loginCredentials = $dbLoginCredentials){
  61. $_SESSION['displayName'] = $dbDisplayName;
  62. header('location: index.php');
  63. break;
  64. }else{
  65. $this->HandleError("Invalid Username or Password!");
  66. header('location: login.php');
  67. return false;
  68. }
  69. }
  70. }
  71. }
  72. fclose($fp);
  73. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement