注册脚本在填写所有字段时始终显示错误

时间:2014-08-30 15:25:40

标签: forms if-statement insert registration

我的注册脚本有点问题。

我正在尝试将行添加到我的mysql数据库中。

这是我的表单验证程序,以确保填写所有字段:

   //Variables from the table
   $user  = $_POST['un'];
   $pass  = $_POST['pw'];
   $rpass = $_POST['rpw'];

   //Prevent MySQL Injections
   $user  = stripslashes($user);
   $pass  = stripslashes($pass);
   $rpass = stripslashes($rpass);

   $user  = mysqli_real_escape_string($user);
   $pass  = mysqli_real_escape_string($pass);
   $rpass = mysqli_real_escape_string($rpass);

   //Check to see if the user left any space empty!
   if($user == "" || $pass == "" || $rpass == "")
   {
      echo "Please fill in all the information!";
   }

这是表格

<form action="register_proc.php" method="post">
    <label for="un">Username</label>
    <input type="text" name="un" id="un" placeholder="username"/>
    <br/>
    <label for="pw">Password</label>
    <input type="password" name="pw" id="pw" placeholder="password"/>
    <br/>
    <label for="rpw">Repeat Password</label>
    <input type="password" name="rpw" id="rpw" placeholder="repeat password"/>
    <br/>

    <input type="submit" name="submit" value="Complete Registration"><br>
    <div style="float: left;">
        <a href="index.php">Home</a>
    </div>
    <div style="float: right;">
        <a href="login.php">Login</a>
    </div>
</form>

我不知道为什么它会继续输出其他声明&#34;请填写所有信息!&#34;

所有$ post变量都具有正确的名称

感谢您即将到来的支持。

0 个答案:

没有答案