Guest User

Untitled

a guest
Sep 23rd, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.12 KB | None | 0 0
  1. /*
  2. @author Sidewind3r
  3. */
  4.  
  5. /*Copy and paste this code and name the file Login.html*/
  6. <html>
  7. <form action="Login.php" method="POST">
  8. Username: <input type="text" name="user"><br />
  9. Password: <input type="password" name="pass"><br />
  10. <input type="submit" value="Login">
  11. </form>
  12. </html>
  13.  
  14.  
  15.  
  16.  
  17.  
  18. /*copy and paste this code and name the file Login.php*/
  19. <?php
  20. /************
  21. **Login.php**
  22. *************/
  23. $User = stripslashes(strip_tags($_POST['user']));
  24. $Pass = stripslashes(strip_tags($_POST['pass']));
  25. $file = file_get_contents("log.txt");
  26. if ($User === null){
  27. die("Please enter a Username");
  28. } if ($Pass === null){
  29. die ("Please enter a Password");
  30. }
  31. $pos = strpos($file, "Username: ".$User." Password: ".$Pass);
  32. if ($pos === false){
  33. die("Wrong username or Password");
  34. } else {
  35. echo "You have been logged in...";
  36. }
  37. ?>
  38.  
  39.  
  40.  
  41.  
  42.  
  43. /*copy and paste this code and name the file Register.html*/
  44. /****************
  45. **Register.html**
  46. *****************/
  47. <html>
  48. <form action="Register.php" method="POST">
  49. Username: <input type="text" name="username"><br />
  50. Password: <input type="password" name="password"><br />
  51. <input type="submit" value="Register">
  52. </form>
  53. </html>
  54.  
  55.  
  56.  
  57.  
  58.  
  59. /*copy and paste this code and name the file Register.php*/
  60. <?php
  61. /****************
  62. **Register.php**
  63. *****************/
  64. $Username = stripslashes(strip_tags($_POST['username']));
  65. $Password = stripslashes(strip_tags($_POST['password']));
  66. $file = file_get_contents("log.txt");
  67. if ($Username === null){
  68. die("Please enter a Username");
  69. }
  70. if ($Password === null){
  71. die ("Please enter a Password");
  72. }
  73. if (strpos($file,"Username: ".$Username)){
  74. die ("That username is already in use");
  75. }
  76. $room_file=file("log.txt",FILE_IGNORE_NEW_LINES);
  77. $room_file[]="Username: ".$Username." Password: ".$Password;
  78. if (count($room_file)>20)$room_file=array_slice($room_file,1);
  79. $file_save=fopen("log.txt","w+");
  80. flock($file_save,LOCK_EX);
  81. for($line=0;$line<count($room_file);$line++){
  82. fputs($file_save,$room_file[$line]."\n");
  83. };
  84. flock($file_save,LOCK_UN);
  85. fclose($file_save);
  86. echo "You have been registered. Please <a href='Login.html'>login</a>";
  87. exit();
  88. ?>
Add Comment
Please, Sign In to add comment