2017-04-16 72 views
0

我正在使用html表單處理註冊頁面,但是當我使用post時,它不提交數據。所有這些代碼都在index.php文件中,因此它指向自己以進行表單操作。POST不適用於HTML表格

<form action="index.php" method="post" style="align-content: left;text-align: center;padding:10px" id="signForm"> 
      Company: <input type="text" value="" name="company"><br> 
      Email: <input style="margin-top:5px" type="text" value="" name="email"><br> 
      Username: <input style="margin-top:5px" type="text" value="" name="username"><br> 
      Password: <input style="margin-top:5px" type="password" value="" name="password"><br> 
      Verify Password: <input style="margin-top:5px" type="password" value="" name="password2"><br> 
      <input style="margin-top:10px" type="submit" value="Submit" name="submitr"> 
     </form> 

這裏是php,它位於頁面上的窗體之上。

if(isset($_POST['submitr'])) { 
    $username = $_POST['username']; 
    $password = $_POST['password']; 
    $password2 = $_POST['password2']; 
    $email = $_POST['email']; 
    $company = $_POST['company']; 
    ... 
} 

我試過輸出變量,但它們總是空白,我似乎無法弄清楚爲什麼。任何幫助將不勝感激!謝謝!

+0

的形式提交正常,或者用JavaScript添加enctype屬性? – Mike

+0

嘗試[啓用錯誤報告](http://stackoverflow.com/a/845025/811240),而不是'echo'使用'var_dump()'來找出變量包含的內容。 – Mike

+0

@Mike表單通常被提交,當我在代碼中使用'var_dump($ _ POST);'時,它會在提交表單之前和之後輸出'array(0){}'。 –

回答