实例代码如下:

<html>
<head>
< >php表单提交给本页的实例</ >
</head>
<body>
<div>
<?php
if ( ! empty( $_POST[\'guess\'] ) ) {
    print \"last guess: \".$_POST[\'guess\'];
}
?>
<form method=\"post\" action=\"<?php print $_SERVER[\'PHP_SELF\']?>\">
<p>
Type your guess here: <input type=\"text\" name=\"guess\" />
</p>
</form>
</div>
</body>
</html>

这里的action设置为$_SERVER['PHP_SELF'];即表示本页,大家可以了解一下php $_SERVER 服务器环境信息

收藏 打印