2016-02-10 113 views
-2

我有一個簡單的註冊表格:表單POST失敗

 <h2>Signup</h2> 
     <form action="actions.php"> 
      Email:<br> 
      <input type="text" name="lastname"> 
      <br> 
      Password:<br> 
      <input type="text" name="lastname"> 
      <br> 
      <br> 
      <input type="submit" name="signupButton" value="submit"> 
     </form> 

這裏是我的actions.php:

<?php 
echo 'test1'; 

if(isset($_POST['signupButton'])){ 
    echo 'test2'; 
} 
?> 

但是當我點擊提交按鈕,顯示的頁面是隻能說明:

test1的

爲何按鈕被點擊未能通過if語句?

+3

你嘗試:'<形式行動= 「actions.php」 方法= 「郵報」>'? – smoqadam

+2

默認的表單方法是GET – RamRaider

+0

@ Fred-ii-〜有趣的是,當它看起來很明顯是代表@ops的錯誤,我同意'$ _POST'調用與表單默認方法 – RamRaider

回答

7

你需要指定的方法類型(POST/GET)

<form action="actions.php" method="POST">