简体   繁体   English

PHP新页面重定向

[英]PHP new page redirect

What I am trying to do is On "Page 1", user fills a form, and when he clicks on "Submit", a new page, say "Page 2" should get automatically created (in the same folder as index.php) in such a way that name of the page is say first_name.php (what the user filled on page 1) and it should display the contents of what he filled in on the first page. 我想做的是在“页面1”上,用户填写一个表格,当他单击“提交”时,将自动创建一个新页面,说“页面2”(与index.php在同一文件夹中)以这样的方式,即页面名称为first_name.php(用户在页面1上填写的内容),并且应该在第一页上显示他填写的内容。 Something like showed in the figure. 如图所示。

数字

showName.php: showName.php:

<?php

   echo "    Your name is {$_REQUEST['name']}";


?>

This is under the assumption that your form contains an input with name=name 这是基于您的表单包含name=name的输入的假设

So a form like this: 所以这样的形式:

<form action="showName.php">
   Enter your name: <input name="name" />
</form>

Eventually you might want some validation on the submit, but for now this should suit for what you want to do. 最终,您可能需要对提交进行一些验证,但是现在这应该适合您想要做的事情。


Update: 更新:

I read your question more carefully -- 我更仔细地阅读了您的问题-

You should NEVER do what you proposed it could lead all kinds of attacks and hacks on your site. 您永远都不要做您建议的操作,它可能导致您网站上的各种攻击和黑客攻击。

You could use a mod-rewrite to seem as if the page went to john.php but really it is showing showName.php?name=john 可以使用mod-rewrite来使页面好像进入john.php但实际上它显示的是showName.php?name=john

No, you should never do this. 不,您永远不要这样做。 Say if this were off your main site, and I were to do something like "../../../etc/passwd%00" as my name, I could rewrite your etc/passwd file, or any other system file. 假设这不在您的主要站点上,并且我将做类似“ ../../../etc/passwd%00”的操作,我可以重写您的etc / passwd文件或任何其他系统文件。 Also, this would make you vulnerable to something called cross site scripting, also known as XSS. 而且,这会使您容易受到跨站点脚本(也称为XSS)之害。

Heheh, OP, I am reiterating the advices of the above 2 posters. OP,Heheh,我要重申上述2个海报的建议。 Never do this. 永远不要这样做。 He could even post a CGI exploit. 他甚至可以发布CGI漏洞。 Use mod_rewrite. 使用mod_rewrite。

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

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