Advertisement
Guest User

Untitled

a guest
May 8th, 2017
157
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.47 KB | None | 0 0
  1. <?php
  2. require 'header.php';
  3.  
  4. $pagecontent = "";
  5. if($_POST['check']) { // if there's a username/pass combo we need to check
  6.     if($_POST['pass']=='[password]' && $_POST['username']=='[username]') { // if inputted pass matches one in db
  7.         setcookie(venice);
  8.         if($_GET[r]) {
  9.             header("Location: $_GET[r]");
  10.         } else {
  11.             header("Location: index.php");
  12.         }
  13.     } else {
  14.         $pagecontent .= "incorrect username/password combination\n";
  15.     }
  16. }
  17.  
  18. $self = $_SERVER['PHP_SELF'];
  19. if($_GET[r]){
  20.     $self .= "?r=$_GET[r]";
  21. }
  22. $username = $_POST['username'];
  23. $pass = $_POST['pass'];
  24.  
  25. $pagecontent .= <<<HTML
  26. <p>
  27. <form action="{action}" method="post">
  28. <input type="hidden" name="check" value="true">
  29. username: <input type="text" name="username" size="30" value="{username}"><br>
  30. password: <input type="password" name="pass" size="30" value="{pass}"><br>
  31. <input type="submit" value="Submit">
  32. </form>
  33. </p>
  34. HTML;
  35.  
  36. $pagecontent = str_replace('{action}', $self, $pagecontent);
  37. $pagecontent = str_replace('{username}', $username, $pagecontent);
  38. $pagecontent = str_replace('{pass}', $pass, $pagecontent);
  39.  
  40. // get the template
  41. $page = file_get_contents('template.html');
  42. // then replace placeholders with content
  43. $page = str_replace('{title}', "log in", $page);
  44. $page = str_replace('{r_content}',"", $page);
  45. $page = str_replace('{footer}', $footer, $page);
  46. $page = str_replace('{content}', $pagecontent, $page);
  47.  
  48. echo $page;
  49. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement