duanba7653 2013-01-15 16:11
浏览 48
已采纳

两种形式相互冲突

I have placed two forms on one page. Bothe forms work fine separately but when they are placed on one page at the same time they conflict with each other. Here are both forms:

Contact Form:

<form name="contactform" id="contactform" method="post" action="#targetAnchorPage2">
<table>
<?php
if (isset($_POST["name"])){
?>
<tr>
 <td colspan="2" class="error">
 <?php
 require_once("contact_send.php");
 ?>
 </td>
</tr>
<?php
}
?>

<tr><td><label for="name" class="<?=$name_class?>">name:</label></td><td><input  type="text" name="name" maxlength="50" value="<?=$name?>"></td></tr>
<tr><td><label for="email" class="<?=$emailaddress_class?>">email:</label></td><td><input  type="text" name="email" maxlength="80" value="<?=$emailaddress?>"></td></tr>
<tr><td colspan="2"><label id="tworows" for="message" class="<?=$message_class?>">your message:</label></td></tr><tr><td colspan="2"><textarea  name="message" cols="22" rows="6" value="<?=$message_class?>"></textarea>
 </td></tr>

<tr>
 <td colspan="2" style="text-align:center"><br /><input class="button" type="submit" value="">   
 </td>
</tr>

</table>
</form>

Subscribe Form:

<form name="subscribeform" id="subscribeform" method="post" action="#targetAnchorPage3">
<table>
<?php
if (isset($_POST["name"])){
?>
<tr>
 <td colspan="2" class="error">
 <?php
 require_once("subscribe_send.php");
 ?>
 </td>
</tr>
<?php
}
?>

<tr><td><label for="name" class="<?=$name_class?>">name:</label></td><td><input type="text" name="name" maxlength="50" value="<?=$name?>"></td></tr>
<tr><td><label for="email" class="<?=$emailaddress_class?>">email:</label></td><td><input type="text" name="email" maxlength="80" value="<?=$emailaddress?>"></td></tr>

<tr>
 <td colspan="2" style="text-align:center"><br /><input class="button" type="submit" value="">   
 </td>
</tr>

</table>
</form>

How can this be solved? Is it caused by the "required_once" command?

  • 写回答

2条回答 默认 最新

  • donglu9896 2013-01-15 16:17
    关注

    I am guessing that since you are showing the required files based on the same criteria isset($_POST['name']) and since both forms have the name field you end up showing the code in both requires regardless of which form is submitted. You should simply change the form field names on on of the forms such that they are different.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 基于卷积神经网络的声纹识别
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?
  • ¥15 有偿求跨组件数据流路径图
  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图