PHP $ _POST给出空值

时间:2016-04-09 05:04:16

标签: php

我不知道发生了什么,但没有价值回报。 Please check if i made any mistake

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:-1)

如果您没有在transfer.php上检查空值或空白值,则值为空白

案例1:你是相同流程的访问文件,然后无需修改任何东西。如果你是访问文件而没有按提交按钮。直接使用url然后帖子是空白的。

e.g。 http://localhost:8080/stackoverflow/transfer.php

案例2:MIME类型问题,enctype =" text / plain"在表单中,这应该解决问题。

<强> from_post.php

<html>
<body>
<form action="transfer.php" method="post" enctype="text/plain">
<input type="text" name="name" value="">
<input type="submit" name="submit" value="submit">
</form>

<强> transfer.php

在这里,您想要检查是否提交按钮。

<?php
 if(isset($_POST['submit']))
 {

     $u=$_POST['name'];
     if(isset($u) || (!is_empty())){

         echo $u;
     }
     else
     {
         echo "the post doesn't have any value";

     }
     echo "<br/>";

 }

?>