PHP通过post在表单提交上动态生成页面
我有一个关于 php 和 mysql 的一般问题。
因此,目前,我在 html 文件中有一个表单,该表单在 sumbit 上发布到 code.php,并在 code.php 中进行一些输入处理。
我将如何在使用 mysql 提交时生成不同的页面并向它们显示 code.php 的结果?
例如,我有我的域 example.com,在提交时,它将生成一个页面 example.com/1.php,之后,如果我刷新页面并再次点击提交,它将生成 example.com/ 2.php?
我知道我的问题非常笼统,只是在寻找教程或代码示例!
I have a general question about php and mysql.
So currently, I have a form in a html file that on sumbit gets posted to a code.php with some input processing in code.php.
How would I go about generating different pages on submit with mysql and showing them the result from code.php?
So for instance, I have my domain example.com and on submit, it would generate a page example.com/1.php, and after, if I were to refresh the page and hit submit again, it would generate example.com/2.php?
I know my question is very general, just looking for a tutorial, or example to code to follow!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我实际上认为您要求的是逐步添加过程之类的东西?
那么我在第1页、第2页、第3页写的内容首先要添加到第4页吗?
如果是这种情况,您应该阅读 PHP 中的 serialize() 函数。
例如,在帖子中你可以这样做:
if( isset($_POST['step1']) )
{
$_SESSION['step1_ok'] = 1;
然后
使用会话来检查用户是否来自上一步。 :)
I actually think what you are asking for is something like a step-by-step add process?
So what I write in page 1, page 2 and page 3 firstly wants to be added on page 4?
If that is the case you should read about serialize()-function in PHP.
E.g. on post you could make this:
if( isset($_POST['step1']) )
{
$_SESSION['step1_ok'] = 1;
}
And then use the session for checking if the user comes from the last step. :)
我不明白你的意思,但要创建一个文件,你可以使用 fopen。
I don't get your point, but to create a file you use fopen.
不确定这一点,您是否想要一个包含多个页面的表单?
您可以在 1 个 php 页面中执行此操作,例如:
如果您想要 1.php、2.php、3.php,.....
那么您应该使用 mod_rewrite 执行某些操作,以将所有这些请求发送到“代码” .php',然后你会执行类似上面的操作来找出他们尝试访问哪些虚拟页面
生成 php 代码,然后将其保存为 php 文件,然后执行该文件会给你带来很多安全问题。
Not sure the point of this, are you trying to have a form that contains multiple pages?
You could just do that in 1 php page with something like:
If you want the 1.php, 2.php, 3.php,.....
Then you should do something with mod_rewrite to make all those requests to to 'code.php' and then you would do something like above to figure out which of the virtual pages they tried accessing
Generating php code and then saving it as a php file which is then executed opens you up to a lot of security issues.
如果您的目标是出于美观原因创建您所描述的 URL,也许您应该研究 mod_rewrite 或类似的东西。
http://articles.sitepoint.com/article/guide-url-rewriting
If your goal is to create the URL as you described for cosmetic reasons, perhaps you should look into mod_rewrite, or something similar.
http://articles.sitepoint.com/article/guide-url-rewriting