简体   繁体   English

转到新的php页面

[英]Go to new php page

I'm wondering the best way to go to a new page. 我想知道转到新页面的最佳方法。 I have a PHP document with a submit button. 我有一个带有提交按钮的PHP文档。 Once that button is pressed, it runs the php code on that page, creates some session variables, then I want it to go to the next page after this code is executed. 一旦按下该按钮,它将在该页面上运行php代码,创建一些会话变量,然后我希望它在执行此代码后转到下一页。 I know with traditional submit buttons you simply have the form that's run being the next page, but how do I link it differently? 我知道使用传统的提交按钮,您只需要运行下一页的表单,但是如何以不同的方式链接它?

您可以使用成功的标头强制重定向,如下所示:

header("Location: second.php");

In a well designed web application, there is no direct relation between the script and the page as the control script is the same for every page and simply shows the page needed based on what was selected or done. 在设计良好的Web应用程序中,脚本和页面之间没有直接关系,因为每个页面的控制脚本都相同,并且仅根据选择或完成的操作显示所需的页面。

There are many ways to implement this but a good starting point would be to look at MVC design. 有很多方法可以实现这一点,但是一个很好的起点是研究MVC设计。

form action=''上设置新页面的URL,以在提交表单后加载另一个脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM