表未通过mysqli_query插入进行更新

时间:2018-07-13 12:57:26

标签: php html mysqli

下面是我的html表单:

<html>
    <head>
        <title>
             Registration
        </title>
   </head>
   <body>
     <form action="backreg.php" method="post">
          user id:<input type="text" name="rid"><br>
          fname:<input type="text" name="rname"><br>
          gender:
          <select name="rgen">
              <option value="male">male</option>
              <option value="female">female</option>
          </select><br>
          dob:<input type="text" name="rdob"><br>
          mobile:<input type="text" name="rmob"><br>
          PASSWORD:<input type="password" name="rpwd">
          <input type="submit" name="rsubmit" value="register">
     </form>

     <a href="index2.php" >already registered ?</a >
   </body>
</html>

捕获上面表格中输入的值的相应php代码(backreg.php)如下:

<?php
$conn = mysqli_connect("localhost", 'root', '', 'manideep_db');
if(isset($_POST['rsubmit'] ))
{
$id=$_POST['rid'];
$name=$_POST['rname'];
$gender=$_POST['rgen'];
$dob=$_POST['rdob'];
$mobile=$_POST['rmob'];
$password=$_POST['rpwd'];
$run=mysqli_query($conn, "INSERT INTO `table_1` (`rid`, `rname`, `rgen`, `rdob`,'rmob','rpwd')VALUES ('$id', '$name', '$gender', '$dob','$mobile','$password')");
if($run)
{
  header('Location: index2.php');
}
echo "error";
}
?>

manideep_db是我的数据库名称。 table_1db内部的表格,其中包含idnamedobgendermobile和{{ 1}}字段。填写表单并提交后,我得到的是输出password,而不是页面被重定向到error。请提出我的代码出了什么问题?谢谢。

0 个答案:

没有答案