dqcwl02022 2014-04-07 04:47
浏览 169
已采纳

HTML和PHP在一个文件中

I'm a PHP newbie trying to sort some basics out. I have a user-form that leads to a mysql select query, which works fine. Every tutorial I have found so far has the standard form tag, ie: action='script.php' method='post'. This obviously opens script.php in a new tab/window though.

If I don't want to display what's fetched from my db on a different webpage I have to put the html and php in one document together. I didn't think this is how you would really want to do it though.

My specific question is when you want to display stuff on the same page do you just put everything in together within one document and let users hit the submit button?

  • 写回答

7条回答 默认 最新

  • dtamho6404 2014-04-07 06:38
    关注
    OR you can put 2 different pages that act as 1 by using INCLUDE FUNCTION
    
    
    script1.php
    <form action="script2.php" method="post" name="myform">
        ...
        <input type="submit" name='submit_button' value="Submit" />
    <input
    </form>
    
    ---------------
    script2.php
    
    include 'script1.php';
    
    if(isset($_POST['submit_button']
    {.......}
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(6条)

报告相同问题?

悬赏问题

  • ¥15 关于用pyqt6的项目开发该怎么把前段后端和业务层分离
  • ¥30 线性代数的问题,我真的忘了线代的知识了
  • ¥15 有谁能够把华为matebook e 高通骁龙850刷成安卓系统,或者安装安卓系统
  • ¥188 需要修改一个工具,懂得汇编的人来。
  • ¥15 livecharts wpf piechart 属性
  • ¥20 数学建模,尽量用matlab回答,论文格式
  • ¥15 昨天挂载了一下u盘,然后拔了
  • ¥30 win from 窗口最大最小化,控件放大缩小,闪烁问题
  • ¥20 易康econgnition精度验证
  • ¥15 msix packaging tool打包问题