php自提交表单示例示例
您不时需要一个工作示例,而我总是在POST&GET请求之间感到困惑。php自提交表单示例示例,php,forms,post,get,Php,Forms,Post,Get,您不时需要一个工作示例,而我总是在POST&GET请求之间感到困惑。 <?php // Check if action is set if(isset($_POST["action"])) { switch($_POST["action"]) { case "number_submit" : // Submission from the number submit form header("Location:
<?php
// Check if action is set
if(isset($_POST["action"]))
{
switch($_POST["action"])
{
case "number_submit" :
// Submission from the number submit form
header("Location: ".$_SERVER["PHP_SELF"]."?number=".$_POST["number"]);
die();
default :
die("Unknown action : ".$_POST["action"]);
break;
}
}
?>
<html>
<head>
<title>Self Submit</title>
</head>
<body>
<?php
if(isset($_GET["number"]))
{
// Display the number if it is set.
?>
Here is the number : <?php echo ($_GET["number"]); ?><br />
<a href="<?php echo $_SERVER["PHP_SELF"]; ?>">Click here to enter another number..</a>
<?php
} else {
// Display the form
?>
<form action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post">
<input type="hidden" name="action" value="number_submit" />
Please enter a number : <input type="text" name="number" />
<input type="submit" value="Submit" />
</form>
<?php
}
?>
</body>
</html>
自首
这是电话号码:
$\u POST
变量是从“单个页面”中的表单提交数据时使用的变量,$\u GET
变量是可以“通过URL传递到另一个页面”的变量,从而允许其他.php页面通过$\u GET
变量使用您的变量
还有$\u请求
,可用于从表单中获取$\u POST
和$\u GET
变量的数据