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.

    评论

报告相同问题?

悬赏问题

  • ¥30 vmware exsi重置后的密码
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 UE5#if WITH_EDITOR导致打包的功能不可用
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题