提交按钮提交错误的表单 [英] Submit button submitting wrong form

查看:105
本文介绍了提交按钮提交错误的表单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我为每个表单提供了2个表单和2个提交按钮。现在问题是每当我点击第二个表格的第二个提交按钮时,该提交按钮正在提交第一个表格!两个提交按钮提交第一个表格!我不知道该怎么办

ps - 第二个提交按钮仅在只有一个表格时有效

 <?php  include('  D:\websites\rushi\html \include\adminmain.php'); ?>  

.width_3_quarter1 {
width:100 %%;
margin-right:100px;
float:left;
}
< h3 class = tabs_involved style = margin-top:10px > 学生列表< / h3 >

<? php
$ servername = ' 本地主机';
$ username = ' root';
$ password = ' ';
$ conn = mysql_connect($ servername,$ username,$ password);

if($ conn === false){
die( ERROR :无法连接。 .mysqli_connect_error());
}

mysql_select_db(' school');

$ query = select * from class;

$ result = mysql_query($ query);

echo 选择班级:;
echo ;
echo ;

while($ row = mysql_fetch_array($ result))
{
echo 。$ row [' class_name']。 ;
}
echo ;

echo < br>
< input type ='submit'
value ='search'
class = \alt_btn \
name ='search'
> ;;
echo < br>< BR>中;
;

?>


<? php

$ servername = ' 本地主机';
$ username = ' root';
$ password = ' ';

$ conn = mysql_connect($ servername,$ username,$ password);

$ _SESSION [' id'] = $ id;

$ search = $ _POST [' SRCH'];

$ sql = SELECT c。*,a。* FROM class c,tedence a WHERE c.student_id = a.student_id AND class_name ='$ search';

mysql_select_db(' school');

$ ds = mysql_query($ sql,$ conn);

echo < form method = \post \name ='myForm'id ='myForm'action ='cuo.php'>;

$ mn = $ ds [' ID ];

if (isset($ _POST [' srch'])){
while($ dr = mysql_fetch_array($ ds))
{
print ;
print ;
print ;
print ;
print ;
print ;
print ;

echo isset($ _ POST [' id'])? ' checked =checked'' ';
print ;
}
}
print < table class = tablesorter cellspacing = 0 >< thead>< tr>< th> ;类标识码< /第><的第i; CLASS_NAME< /第><的第i; student_name< /第><的第i; student_id数据< /第><的第i; TEACHER_NAME< /第><的第i;状态< /次> ;< th> date< / th>< / tr>< / thead>< tbody>< tr>< td width = 100 >。($ dr [ class_id])。 < ; / td>< td width = 100 >。($ dr [ class_name])。 < / td>< td width = 100 >。($ dr [ student_name])。 < / td>< td width = 100 >。($ dr [ student_id]). < / td>< td width = 100 >。($ dr [ teacher_name])。 < / td>< td width = 100 >< input type = \checkbox \name = \attd [] \ value =。$ dr [' id']。 < / td>< td width = 100 < span class =code-string>
>。($ dr [ date])。 < / td> < / TR GT&;< / tbody的>< /表>;
echo < br>
< input type ='submit'
value ='update'
class = \alt_btn \
name ='update'
>;
echo ;

mysql_close($ conn);
?>





我有什么试过:



我试过javascript,jquery,ajax但没什么用呢!

解决方案

< blockquote> servername = ' localhost';


用户名 = ' ;


密码 = ' ';


I have 2 forms and 2 submit button for each form. now the problem is whenever i click on 2nd submit button of 2nd form,that submit button is submiting 1st form! both submit button submit 1st form! i dont know what to do now
ps - 2nd submit button works only when there is only one form

<?php include('D:\websites\rushi\html\include\adminmain.php'); ?>

.width_3_quarter1 {
width: 100%%;
margin-right: 100px;
float: left;
}
		<h3 class="tabs_involved" style="margin-top: 10px">student list</h3>                    
			 
<?php 
$servername = 'localhost';
$username = 'root';
$password = '';
$conn = mysql_connect($servername, $username, $password);
 
if($conn === false){
    die("ERROR: Could not connect. " . mysqli_connect_error());
}
 
 mysql_select_db('school');

$query = "select * from class";

$result = mysql_query($query);	

echo "Select class : ";
echo "";
echo "";

 while($row=mysql_fetch_array($result))
 { 
       echo "".$row['class_name']."";
 }
 echo "";

echo "<br>
      <input type='submit'
	  value = 'search'
	  class=\"alt_btn\"
      name='search' 
      >";
 echo "<br><br>";
"";

 ?>


<?php

$servername = 'localhost';
$username = 'root';
$password = '';

$conn = mysql_connect($servername, $username, $password);
    
		 $_SESSION['id']=$id; 

$search = $_POST['srch'];
	
$sql = "SELECT c.*,a.* FROM class c, attendence a WHERE c.student_id=a.student_id AND class_name = '$search'";

mysql_select_db('school');

$ds = mysql_query($sql,$conn);

echo "<form  method = \"post\" name ='myForm' id ='myForm' action='cuo.php'>";

$mn = $ds['id'];

if (isset ($_POST['srch'])){
while($dr = mysql_fetch_array($ds))
{
	print"";
	print "";
	print ""; 
	print "";
	print "";
	print "";
	print "";
	
	 echo isset($_POST['id']) ? 'checked="checked" ' : '';
	print "";
	}	
}
  print "<table class="tablesorter" cellspacing="0"><thead> 	<tr><th>class_id</th><th>class_name</th><th>student_name</th><th>student_id</th><th>teacher_name</th><th>status</th><th>date</th></tr></thead><tbody><tr><td width="100">".($dr ["class_id"])."</td><td width="100">".($dr ["class_name"])."</td><td width="100">".($dr ["student_name"])."</td><td width="100">".($dr ["student_id"])."</td><td width="100">".($dr ["teacher_name"])."</td><td width="100"><input type=\"checkbox\" name=\"attd[]\" value=".$dr['id']."</td><td width="100">".($dr ["date"])."</td></tr></tbody></table>";
echo "<br>
      <input type='submit'
	  value = 'update'
	  class=\"alt_btn\"
	  name='update'
      >";
  echo "";

mysql_close($conn);
?>



What I have tried:

i've tried javascript,jquery,ajax but nothing works!

解决方案

servername = 'localhost';


username = 'root';


password = '';


这篇关于提交按钮提交错误的表单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆