PHP:执行操作时保持同一页面[关闭]

I am trying to find a way to make a password enter form without changing the page. Right now I am using it like this:

Enter:

<form action="developer.php" method="post">
<p>Password:</p><input type="password" name="password"/><br>
<input type="submit"/>
</form>

developer.php:

<?php
$input = $_POST["password"];
if ($input != "mySecretPassword"){
header("Location: site/develop.php");
exit;
}
?>

And underneath de code from above the code to draw the whole page.

But I would like to stay at the same page (develop.php) instead of redirecting to developer.php, how should I do that?

Thanks

You must use AJAX. It will help you achieve this. AJAX with jQuery is widely used to achieve aschnchrnymous loading. You can learn ajax here - > http://www.w3schools.com/jquery/jquery_ajax_intro.asp . Your code for the jQuery will be :-

$("button").click(function(){
  $.post("developer.php",
  {
    password:$("#pass-field").val(),
  },
  function(data,status){
   alert("Data: " + data + "
Status: " + status);
});
});

The action="developer.php" is forwarding you off the page. Put the logic in the developer.php file on the $_post handler.

At the very top of your page put

<?
    if ($_SERVER["REQUEST_METHOD"] == "POST")
    {
        // stuff from your developer.php file
        // The logic that compares the input to the password on file
    }
?>
<!Doctype html>
<html>
. . . . . .