Advertisement
Guest User

Login Cuser

a guest
Oct 13th, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.42 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4.  
  5. if(!isset($_POST['uname']) || !isset($_POST['pass'])){}
  6. if($_POST["uname"] == "" || $_POST["pass"] == ""){
  7.     echo "<h1>You must require a username or password!</h1>";
  8.     echo "<h2><a href='/Access'>Go Back</a></h2>";
  9. }
  10.  
  11. $ourFileName = "Users/" . $_POST['uname'] ."_pass.txt";
  12.  
  13. $ourFileHandle = fopen($ourFileName, 'w') or die("can't open file");
  14.  
  15. fclose($ourFileHandle); $fopen = fopen($ourFileName, 'a');
  16.  
  17. fwrite($fopen, $_POST['pass']);
  18.  
  19. fclose($fopen);
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30. if(!isset($_POST['uname']) || !isset($_POST['pass'])){
  31.   echo "You must fill all required areas.<a href='/Access'>Go Back</a>";
  32. }
  33.  
  34. $myfile = "Users/" . $_POST['uname'] ."_pass.txt";
  35. $username = $_POST['uname'];
  36. $postpass = $_POST['pass']; //Above just helps tidy up
  37. $exists = file_exists($myfile);
  38. if($exists){ $file = $myfile;
  39. $fh = fopen($file, 'r');
  40. $pass = fread($fh, filesize($file));
  41. fclose($fh); //Above checks if exists and sets pass as the real password
  42. }
  43. if(($exists) and ($pass == $postpass)){
  44. //Above checks if the real pass is equal to the entered pass
  45.  
  46. setcookie("Username",$username,time()+86400, "/");
  47. //Username
  48. setcookie("Password",$pass,time()+86400, "/");
  49. //Password
  50.  
  51.  
  52. //Cookies That Expire Within A Day For Profile Reasons
  53.  
  54. ?>
  55. <script>
  56.     window.location.assign("done.php");
  57. </script>
  58. <?php
  59. }else{
  60. print "Username or password was incorrect.<a href='/Access'>Go Back</a>";
  61. }
  62. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement