我的页面中有三种表单,具有不同的提交按钮,并且所有HTML都已正确关闭。
所有表单的值都不同任何形式的只有这些表单值在数据库中提交..其他表单字段不会为空..我如何解决这个问题..我已经为单个表单完成了编码

        <form class="form" method="POST" name="pool">
  <label for="name1">Ist Player Name</label>
 <input type="text" name="fname" id="fname"  />
    <label for="name2">2nd Player Name</label></td><td><input type="text" name="sname"    id="sname"   />
 <label for="stime">Start Time</label>
 <input type="text" name="stime" id="stime"
      <label for="stime">End Time</label>
       input type="text" name="etime" id="etime" />
<input type="submit" value="Confirm" name="pool" id="pool"  />
 </form>


与第二和第三形式.name一样,都是所有形式的变化。

   <?php
   $con = mysql_connect("localhost","root","");
    mysql_select_db("snookar", $con);

   if(isset($_POST['pool']))
   {
    /* all procees to save record */
   }
     then 2 nd form
     if(isset($_POST['snooke']))
   {
    /* all procees to save record */
   } and so on...


现在我如何才能完成此仅指定的表单值提交并且另一种表单不为空...

最佳答案

您可以执行以下操作

<form class="form" method="POST" name="pool1">
     <!-- Form input fields -->
     <input type="submit" value="Confirm" name="poolbtn1" id="poolbtn1"  />
</form>

<form class="form" method="POST" name="pool2">
     <!-- Form input fields -->
     <input type="submit" value="Confirm" name="poolbtn2" id="poolbtn2"  />
</form>


现在使用jquery提交表单,

$("#pool1").submit(function(e) {
   //Do your task here
   return false; //this will prevent your page from refreshing
}

$("#pool2").submit(function(e) {
   //Do your task here
   return false; //this will prevent your page from refreshing
}

关于php - 所有三种形式都可以一键获得空,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/16581262/

10-12 00:09
查看更多