Post 方法在 PHP 中不起作用
Post method not working in PHP
我尝试了其他一些 post,但从未成功。
我在 html 文件中的 php 表单是:
<form action="test.php" method="POST">
VAR:<input type="text" name="var"><br>
<input type="submit">
</form>
我在 test.php 中收到变量 <br>
$_POST['var'] ---- > doesn't work! <br>
Tried, $_REQUEST['var'] ----> doesn't work!
我使用 get 请求尝试了表单,它在 test.php 的另一端通过使用 $_GET['var'] 和 $_REQUEST['var'] 就像一个魅力
我可以以任何方式解析 post 请求形式的请求,从该表单到 test.php ..
感谢您的帮助!
谢谢。
你有没有检查过'submit'的值是否像
一样被设置了
if(isset($_POST['submit'])){
$_POST['var']
}
您的 html 标签有误。
您需要像这样为其设置名称
<input type= "submit" name= "submit">
然后当您像这样提交表单时:
if(isset($_POST['submit'])) {
// you will set your post var, try to print it with
print_r($_POST);
}
而且您不需要在输入中添加“/”,没有它也能正常工作。
抱歉,我犯了语法错误,忘记关闭 if 语句。现在是正确的。
Try this what is post on same page
<?php
if(isset($_POST['var_name'])) {
print_r($_POST);
}
exit();
?>
<form action="" method="POST">
<input type="text" name="var_name"><br>
<input type="submit" name="Save">
</form>
已更新至 PHP 7.0,现在可以使用了!
感谢大家的帮助!
我尝试了其他一些 post,但从未成功。
我在 html 文件中的 php 表单是:
<form action="test.php" method="POST">
VAR:<input type="text" name="var"><br>
<input type="submit">
</form>
我在 test.php 中收到变量 <br>
$_POST['var'] ---- > doesn't work! <br>
Tried, $_REQUEST['var'] ----> doesn't work!
我使用 get 请求尝试了表单,它在 test.php 的另一端通过使用 $_GET['var'] 和 $_REQUEST['var'] 就像一个魅力 我可以以任何方式解析 post 请求形式的请求,从该表单到 test.php ..
感谢您的帮助! 谢谢。
你有没有检查过'submit'的值是否像
一样被设置了if(isset($_POST['submit'])){
$_POST['var']
}
您的 html 标签有误。 您需要像这样为其设置名称
<input type= "submit" name= "submit">
然后当您像这样提交表单时:
if(isset($_POST['submit'])) {
// you will set your post var, try to print it with
print_r($_POST);
}
而且您不需要在输入中添加“/”,没有它也能正常工作。
抱歉,我犯了语法错误,忘记关闭 if 语句。现在是正确的。
Try this what is post on same page
<?php
if(isset($_POST['var_name'])) {
print_r($_POST);
}
exit();
?>
<form action="" method="POST">
<input type="text" name="var_name"><br>
<input type="submit" name="Save">
</form>
已更新至 PHP 7.0,现在可以使用了!
感谢大家的帮助!