drzb7969753 2013-04-16 03:11
浏览 75

当存在其他表单时,调用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>" .
    }
  • 写回答

2条回答

  • douwen3362 2013-04-16 03:22
    关注

    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.

    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)