Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- session_start();
- if($_SERVER['REQUEST_METHOD'] == "POST")
- {
- if($_POST['user'] === 'mysecret' && $_POST['pass'] === 'page')
- $_SESSION['auth'] = true;
- }
- if(isset($_SESSION['auth']))
- {
- ?>
- <html>
- <body>
- <div id="anothercontainer"> </div>
- <div id="container">
- <p id="mycontent"> Here is my new content </p> </div>
- </body>
- </html>
- <?php
- exit();
- }
- ?>
- <html>
- <body>
- <form id="changing" action="test3.php" method="POST">
- User:
- <input type="text" name="user" />
- Pass:
- <input type="password" name="pass" />
- <input type="submit" value="Send" />
- </form>
- <div id="content"> Here is the content to be updated </div>
- <script src="scripts/jquery-3.2.0.js"></script>
- <script>
- $('#changing').on('submit', function(e) {
- e.preventDefault();
- var $content = $('#content');
- var details = $('#changing').serialize();
- $.post('test3.php', details, function(data) {
- $content.html( $(data).find('#container') );
- });
- });
- </script>
- </body>
- </html>
- success: function(data) { // Show content
- $content.html( $(data).find('#container') ).hide().fadeIn(400);
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement