如何根据他们的表单输入重定向用户? [英] php - How do I redirect a user based on their form input?
本文介绍了如何根据他们的表单输入重定向用户?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想要一个带有一个文本框和一个提交按钮的简单表单。例如:如果用户在文本框中输入foobar,并输入,他们应该被重定向到mysite.com/browse/foobar
有谁知道我可以在PHP中做到这一点?谢谢
解决方案
表格:
< form action =index.phpmethod =get>
< input type =textname =q/>
< input type =submit/>
< / form>
index.php
header(Location:http://example.com/browse/\".$_GET['q']);
注意:这不是很好的做法,但是它可以工作。
I want a simple form with one text box and a submit button. For example: If a user enters "foobar" into the text box and hits enter, they should be redirected to mysite.com/browse/foobar
Does anyone know how I can do this in php? thanks
解决方案
The Form:
<form action="index.php" method="get">
<input type="text" name="q" />
<input type="submit" />
</form>
index.php
header("Location: http://example.com/browse/".$_GET['q']);
Note: this is not good practice but it works.
这篇关于如何根据他们的表单输入重定向用户?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文