[英]PHP form called to HTML file doesn't work when other forms are present
我在PHP文件中使用“ include”命令调用了多种形式。 如果我将include命令放在HTML页面中的其他表单之前,那么它将起作用。 问题是我需要在其他表格下方调用“ include”命令。 我想出的解决方案是在页面开头调用PHP文件并隐藏div。 然后,我再次在页面底部调用该文件,从而解决了该问题。 还有其他解决方案吗? 为什么这样做呢?
非工作示例:
<form></form>
<form></form>
include 'phpfilewithotherforms.php';
工作示例,但不可行:
include 'phpfilewithotherforms.php';
<form></form>
<form></form>
工作示例:
<div style="display:none;">include 'phpfilewithotherforms,php';</div>
<form></form>
<form></form>
include 'phpfilewithotherforms.php';
我正在调用的PHP文件示例:
while($row = mysql_fetch_array($result))
{
echo "<div style='padding:20px;margin:15px;background:offwhite;border-style:solid;border-width:1px;border-color:lightgray;'>" .
"<form method='post' name='example'>" .
"<span class='detail'><b>Title:</b> " .
$row['mytitle'] .
" " .
"<input type='hidden' value='" . stripslashes($row['mytitle']) . "' . name='title'>" .
"<span style='float:right'>" .
"<input type='submit' value='Edit' name='edit'>" .
"<input type='submit' value='Preview' name='preview'>" .
"</span>" .
"</form>" .
}
您必须按顺序工作。 我将包含的文件一分为二,一个包含表单之前所需的代码,另一个包含表单之后所需的代码。
我通常用<? PHP CODE ?>
<? PHP CODE ?>
<div style="display:none;"><?include 'phpfilewithotherforms,php';?></div>
你想念那些吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.