
我在HTML中定义了2个表单,但是用PHP只能调用第二个表单的时候页面没有反应、麻烦各位帮忙看看
HTML程序:<formaction="insert.php"id="f1"name="form1"method="post"><p>添加:</p>姓名:<inputty...
HTML程序:
<form action="insert.php" id="f1" name="form1" method="post">
<p>添加:</p>
姓名:<input type="text" name="name" />
学号:<input type="text" name="studentid" />
成绩:<input type="text" name="score">
<input type="submit" name="submit" value="提交"/>
</form>
<form action >
<form action="search.php" id="f2" name="form2" method="post">
<p>查询:</p>
请输入你想查询的ID:<input type="text" name="Pkey" />
<input type="submit" name="submit" value="提交" />
search.php程序:
<?php
echo ddddd;
return;
$con = mysql_connect("localhost","root","");//连接数据库
if(!$con)//判断是否连接上数据库
{
die('Could not connect:' .mysql_error());
}
mysql_select_db("my_db",$con);//连接My_db表
$if(!isset($_POST['Pkey']))
{
echo "你输入为空!";
}
$search=mysql_query("select*from text where Pkey='"$_POST['Pkey']"'");
while($row=mysql_fetch_array($search))
{
echo $row['Pkey'] . " " . $row['Name']. " " . $row['StudentId']. " " . $row['ReferenceDate']. " " . $row['Score'];
}
mysql_free_result($result);
mysql_close($con);
?> 展开
<form action="insert.php" id="f1" name="form1" method="post">
<p>添加:</p>
姓名:<input type="text" name="name" />
学号:<input type="text" name="studentid" />
成绩:<input type="text" name="score">
<input type="submit" name="submit" value="提交"/>
</form>
<form action >
<form action="search.php" id="f2" name="form2" method="post">
<p>查询:</p>
请输入你想查询的ID:<input type="text" name="Pkey" />
<input type="submit" name="submit" value="提交" />
search.php程序:
<?php
echo ddddd;
return;
$con = mysql_connect("localhost","root","");//连接数据库
if(!$con)//判断是否连接上数据库
{
die('Could not connect:' .mysql_error());
}
mysql_select_db("my_db",$con);//连接My_db表
$if(!isset($_POST['Pkey']))
{
echo "你输入为空!";
}
$search=mysql_query("select*from text where Pkey='"$_POST['Pkey']"'");
while($row=mysql_fetch_array($search))
{
echo $row['Pkey'] . " " . $row['Name']. " " . $row['StudentId']. " " . $row['ReferenceDate']. " " . $row['Score'];
}
mysql_free_result($result);
mysql_close($con);
?> 展开
展开全部
你的第二个表单书写错误,首先<form>的标签书写有毛病,另外要提交的表单的内容没有放进<form></form>之中,这样提交不过去数据的。
修改成这样:
<form action="search.php" id="f2" name="form2" method="post">
<p>查询:</p>
请输入你想查询的ID:<input type="text" name="Pkey" />
<input type="submit" name="submit" value="提交" />
</form>
这样应该就没问题了
修改成这样:
<form action="search.php" id="f2" name="form2" method="post">
<p>查询:</p>
请输入你想查询的ID:<input type="text" name="Pkey" />
<input type="submit" name="submit" value="提交" />
</form>
这样应该就没问题了
追问
额、表示还是不行、。就是你说一下用JS怎么做那个两个表单可以么....因为我在search.php里面输出一个简单的字符串都不能输出在页面上、还是用JS来做2个表单的问题
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询