表格不提交数据

时间:2014-04-26 22:59:46

标签: php html forms

我在html中有一个注册表单,但它没有向php文件提交任何数据。奇怪的是,对我来说,在同一页面上看起来完全相同的形式确实有效,而这个曾经工作过。我可能在某处意外地改变了一些事情。

表格:

<form action="http://test.com/register.php" method="POST" enctype="multipart/form-data">
  <fieldset>
    <div align="left">
    <label>Username</label>
    <input type="text" required class="span11" name="fUsername" id="Username" placeholder="username">

<label>Password</label>
    <input type="password" required class="span11" name="fPassword" id="Password" placeholder="password">

    <label>Retype password</label>
    <input type="password" required class="span11" name="fRetypepassword" id="Retypepassword" placeholder="retype password">

    <label>Phone number</label>
    <input type="text" required class="span11" name="fPhone" id="Phone" placeholder="+... international format">

    <label>E-Mail</label>
    <input type="email" required class="span11" name="fEmail" id="Email" placeholder="e-mail">
<br><br>
    <button type="submit" class="btn btn-info">Register</button>
  </div>
  </fieldset>
</form>

PHP:

$username = htmlspecialchars($_GET['fUsername']); 
$password=htmlspecialchars($_GET['fPassword']);
$passwordmatch=htmlspecialchars($_GET['fRetypepassword']);
$email=htmlspecialchars($_GET['fEmail']);
$phone=htmlspecialchars($_GET['fPhone']);

echo $username;

1 个答案:

答案 0 :(得分:6)

表单正在使用方法POST发送数据,但您正尝试从$ _GET中读取它。

尝试: -

$username = htmlspecialchars($_POST['fUsername']); 
$password = htmlspecialchars($_POST['fPassword']);
$passwordmatch = htmlspecialchars($_POST['fRetypepassword']);
$email = htmlspecialchars($_POST['fEmail']);
$phone = htmlspecialchars($_POST['fPhone']);