Advertisement
Guest User

Untitled

a guest
Apr 11th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.44 KB | None | 0 0
  1. <?php
  2.  
  3. session_start();
  4. if($_SERVER['REQUEST_METHOD'] == "POST")
  5. {
  6. if($_POST['user'] === 'mysecret' && $_POST['pass'] === 'page')
  7. $_SESSION['auth'] = true;
  8. }
  9.  
  10. if(isset($_SESSION['auth']))
  11. {
  12. ?>
  13. <html>
  14. <body>
  15. <div id="anothercontainer"> </div>
  16. <div id="container">
  17. <p id="mycontent"> Here is my new content </p> </div>
  18. </body>
  19. </html>
  20. <?php
  21. exit();
  22. }
  23.  
  24. ?>
  25.  
  26. <html>
  27. <body>
  28. <form id="changing" action="test3.php" method="POST">
  29. User:
  30. <input type="text" name="user" />
  31. Pass:
  32. <input type="password" name="pass" />
  33. <input type="submit" value="Send" />
  34.  
  35. </form>
  36. <div id="content"> Here is the content to be updated </div>
  37.  
  38. <script src="scripts/jquery-3.2.0.js"></script>
  39. <script>
  40. $('#changing').on('submit', function(e) {
  41. e.preventDefault();
  42. var $content = $('#content');
  43. var details = $('#changing').serialize();
  44. $.post('test3.php', details, function(data) {
  45. $content.html( $(data).find('#container') );
  46. });
  47. });
  48. </script>
  49. </body>
  50. </html>
  51.  
  52. success: function(data) { // Show content
  53. $content.html( $(data).find('#container') ).hide().fadeIn(400);
  54. },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement