2017-01-07 55 views
-1

這是奇怪的,但我的表單不通過POST數據。表單不傳遞到php

這裏是形式

<form method="POST" action="process/processor.php"> 
<input name="name3" type="text"> 
<input type="submit" name="submit"> 
</form> 

這裏是PHP

<?php  
if(isset($_POST['submit']) AND $_SERVER['REQUEST_METHOD'] == "POST"){ 

$name = $_POST['name3']; 

echo $name; 

} 
else{ 
    echo 'lol'; 
} 

?> 

這裏就是它得到了驚人的

var_dump($_POST)array(0) { },另一方面,var_dump($_GET)rray(2) { ["name3"]=> string(6) "fghjmk" ["submit"]=> string(6) "Submit" }

它看起來像我獲取數據和POST沒有數據。這對我來說很奇怪。有什麼建議麼?

,並沒有什麼呼應了可變$name

+0

使用===等於。 if(isset($ _ POST ['submit'])AND $ _SERVER ['REQUEST_METHOD'] ===「POST」){ – xFighter

+0

這不能解決問題 – Neville

+0

看看這個http://stackoverflow.com/問題/ 10943060/isset-postsubmit-vs-serverrequest-method-post – xFighter

回答

0
<form method="POST" action="process/processor.php"> 
<input name="name3" type="text"> 
<input type="submit" name="submit"> 
</form> 

instead of <input type="submit" name="submit">, use <input type="submit" name="submit" value='submit'> 

the $_POST['submit'] might be empty using <input type="submit" name="submit">. so, i think is not getting into the block code.