从多个表单中获取值

时间:2014-05-08 16:08:22

标签: php html html-form

我想从多种形式的数据库中获取值

这里是表格

 <td width="191"><div align="left"><strong>First Name</strong></div></td>
          <td width="336" colspan="2"><form id="form3" name="form3" method="post" action="Register.php">
            <label for="textfield2"></label>
            <input type="text" size="50px" name="fname" id="fname" />
            </form></td>
          </tr>
        <tr>
          <td><div align="left"><strong>Last Name</strong></div></td>
          <td colspan="2"><form id="form4" name="form4" method="post" action="Register.php">
            <label for="textfield3"></label>
            <input type="text" size="50px" name="lname" id="lname" />
            </form></td>
          </tr>
        <tr>
          <td><div align="left"><strong>User Name</strong></div></td>
          <td colspan="2"><form id="form5" name="form5" method="post" action="Register.php">
            <label for="textfield4"></label>
            <input type="text" size="50px" name="uname" id="uname" />
            </form></td>
          </tr>
        <tr>
          <td><div align="left"><strong>Password</strong></div></td>
          <td colspan="2"><form id="form6" name="form6" method="post" action="Register.php">
            <label for="textfield5"></label>
            <input type="password" size="50px" name="password" id="password" />
            </form></td>
          </tr>

PHP:

  <?php 

    ;
        $con = mysql_connect("localhost","root","");

                    if(!$con)
                    {
                        die('could not connect: ' . mysql_error()); 
                    }

                    mysql_select_db("toolmate",$con);

                            $sql ="

                    INSERT INTO  `toolmate`.`supply` (
                    `email` ,
                    `fname` ,'lname',
                    `username:`
                    )
                    VALUES ('".$_POST["email"]."',  '".$_POST["fname"]."', '".$_POST["lname"]."' ,'".$_POST["uname"]."')";

                            mysql_query($sql, $con); //Execute the query
                    mysql_close($con);  //Close the connection
?>

但我收到错误,说帖子[“email”]帖子[“fname”]未找到

1 个答案:

答案 0 :(得分:0)

你有3种不同的

<form id="form3" name="form3" method="post"

在代码中,因此每个页面都有单独的action页面,在此行中:

<form id="form4" name="form4" method="post" action="Register.php">

操作页面被称为register.php,但其余表单只是空白。

要解决此问题,请删除所有<form>代码,并将inputs放入<form>register.php


并且旁注:

在提出这些基本问题之前,您真的需要更新HTML和PHP知识!!

相关问题