duanmuybrtg1231 2014-04-22 18:38
浏览 52
已采纳

多个PHP表单函数

Im having some troubling getting some HTML/PHP to work. Ive got a HTML file that contains 3 basic table areas. In one area I have a input field and a button that communicates with a SQL database to remove the entry supplied from the HTML box. In the second table line I have a form to add a new item into the database.

However when I press the button in the second table area it runs the first PHP function. Am I missing anything?

<table width="651" height="231" border="1">
  <tr>
  <td width="1163" height="23">&nbsp;</td>
</tr>
<tr>
<td height="96">
<table>
<form method=post action="removeRecord.php">
<input type="text" name="boatNumber" font color="white"> Enter a boat to remove<br>
<input type=submit value="Remove boat">
</table>
</td>
</tr>
<tr>
<td height="102">
<h1>Register a new boat.</h1>
<table>
<form method=post action="addRecord.php">
<input type="text" name="boatNumberNew" font color="white"> Enter the boats number.<br>
<input type="text" name="boatType" font color="white"> Enter the type of boat.<br>
<input type="text" name="decks" font color="white"> :Number of Decks<br>
<input type="text" name="cabins" font color="white"> :Number of cabins<br>
<input type="text" name="location" font color="white"> Location.<br>
<input type="text" name="rent" font color="white"> Rent.<br>
<input type="text" name="staffNumber" font color="white"> Enter assigned staff member.<br>
<input type="text" name="branchNumber" font color="white"> Enter assigned branch.<br>
<input type="text" name="ownerNumber" font color="white"> Enter owner number.<br>
<input type=submit value="Add boat">
</table>
</td>
</tr>
</table>
  • 写回答

4条回答 默认 最新

  • douhe1864 2014-04-22 18:41
    关注

    You're missing closing </form> tags for both your forms.

    Plus, quotes around type=submit and method=post

    Here's a rewrite:

    <table width="651" height="231" border="1">
      <tr>
      <td width="1163" height="23">&nbsp;</td>
    </tr>
    <tr>
    <td height="96">
    <table>
    <form method="post" action="removeRecord.php">
    <input type="text" name="boatNumber" font color="white"> Enter a boat to remove<br>
    <input type="submit" value="Remove boat">
    </form>
    </table>
    </td>
    </tr>
    <tr>
    <td height="102">
    <h1>Register a new boat.</h1>
    <table>
    <form method="post" action="addRecord.php">
    <input type="text" name="boatNumberNew" font color="white"> Enter the boats number.<br>
    <input type="text" name="boatType" font color="white"> Enter the type of boat.<br>
    <input type="text" name="decks" font color="white"> :Number of Decks<br>
    <input type="text" name="cabins" font color="white"> :Number of cabins<br>
    <input type="text" name="location" font color="white"> Location.<br>
    <input type="text" name="rent" font color="white"> Rent.<br>
    <input type="text" name="staffNumber" font color="white"> Enter assigned staff member.<br>
    <input type="text" name="branchNumber" font color="white"> Enter assigned branch.<br>
    <input type="text" name="ownerNumber" font color="white"> Enter owner number.<br>
    <input type="submit" value="Add boat">
    </form>
    </table>
    </td>
    </tr>
    </table>
    

    Another rewrite applying Marc B's recommendations:

    <table width="651" height="231" border="1">
      <tr>
      <td width="1163" height="23">&nbsp;</td>
    </tr>
    <tr>
    <td height="96">
    <form method="post" action="removeRecord.php">
    <table>
    
    <input type="text" name="boatNumber" font color="white"> Enter a boat to remove<br>
    <input type="submit" value="Remove boat">
    
    </table>
    </form>
    </td>
    </tr>
    <tr>
    <td height="102">
    <h1>Register a new boat.</h1>
    <form method="post" action="addRecord.php">
    <table>
    
    <input type="text" name="boatNumberNew" font color="white"> Enter the boats number.<br>
    <input type="text" name="boatType" font color="white"> Enter the type of boat.<br>
    <input type="text" name="decks" font color="white"> :Number of Decks<br>
    <input type="text" name="cabins" font color="white"> :Number of cabins<br>
    <input type="text" name="location" font color="white"> Location.<br>
    <input type="text" name="rent" font color="white"> Rent.<br>
    <input type="text" name="staffNumber" font color="white"> Enter assigned staff member.<br>
    <input type="text" name="branchNumber" font color="white"> Enter assigned branch.<br>
    <input type="text" name="ownerNumber" font color="white"> Enter owner number.<br>
    <input type="submit" value="Add boat">
    
    </table>
    </form>
    </td>
    </tr>
    </table>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 nrf52810-c三个a 程序
  • ¥15 lego-loam跑出来的roll误差很大
  • ¥50 求一个半透明没有锯齿的圆角窗体的实现例子
  • ¥15 STM32cubeMX里的FreeRTOS无法释放内存
  • ¥15 CATIA有些零件打开直接单机确定终止
  • ¥15 请问有会的吗,用MATLAB做
  • ¥15 phython如何实现以下功能?查找同一用户名的消费金额合并—
  • ¥15 孟德尔随机化怎样画共定位分析图
  • ¥18 模拟电路问题解答有偿速度
  • ¥15 CST仿真别人的模型结果仿真结果S参数完全不对