当存在其他表单时,调用HTML文件的PHP表单不起作用

I have multiple forms in a PHP file that I call with the 'include' command. If I put the include command before the other forms in the HTML page then it works. The problem is that I need to call the 'include' command below the other forms. The solution I came up with was to call the PHP file at the beginning of the page and hide the div. I then called the file again at the bottom of the page which fixed the problem. Is there another solution? Why is it doing this?

Non working example:

    <form></form>
    <form></form>
    include 'phpfilewithotherforms.php';

working example but not viable:

    include 'phpfilewithotherforms.php';
    <form></form>
    <form></form>

working example:

    <div style="display:none;">include 'phpfilewithotherforms,php';</div>
    <form></form>
    <form></form>
    include 'phpfilewithotherforms.php';

Sample of PHP file that I'm calling:

    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>" .
    }
drxdai15012937753
drxdai15012937753 感谢你们。使用php缓冲区就可以了。
7 年多之前 回复
dqr6434
dqr6434 我有一个类似的问题,让我感到难过,正如丹尼所说,使用ob_start和ob_flush强制顺序命令到浏览器。这是我唯一的解决方法,从未发现为什么它不起作用,因为我严格按顺序排序<form>。
7 年多之前 回复
douhaoqiao9304
douhaoqiao9304 也许使用输出缓冲来防止在生成完成的html页面之前将数据发送到浏览器。
7 年多之前 回复

2个回答



你必须按顺序工作。 我将包含的文件拆分为两个,一个是表单前需要的代码,另一个是表单后需要的代码。 </ p>
</ div>

展开原文

原文

You have to work in order. I would split the included file in two, one with the code needed before forms, and the other with the code needed after forms.

dtyyrt4545
dtyyrt4545 看着你的代码。 首先,我会检查你的error_log是否存在任何语法错误。 在PHP中,不需要连接行。 另外,看看你的HTML,还有一些额外的“。”。
7 年多之前 回复
doutangqi4444
doutangqi4444 我这样做的方式是最好的解决方案,还是我只是使用解决方法?
7 年多之前 回复

I usually write PHP inside HTML with <? PHP CODE ?>

<div style="display:none;"><?include 'phpfilewithotherforms,php';?></div>

Are you missing those?

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐