Using <META> to redirect a form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sharpnova
Forum Newbie
Posts: 1
Joined: Fri Aug 22, 2008 6:13 pm

Using <META> to redirect a form

Post by sharpnova »

I have a website which has a google search bar on the front page.

I implemented it like this:

<form action="http://www.google.com/search" name="googleform">
<input name=q value="" size=40>
</form>


Recently I wanted to make a sneaky little addition:

I wanted to make it so when the user enters a special password in that form box, it redirects them to a secret page.

I did it like this:

$arg = $_REQUEST['q'];

if ($_REQUEST['q']=="mypassword") echo "<meta http-equiv='refresh'
content='0; url=http://www.mysite.com/secretpage.html'>";

elseif ($_REQUEST['q']) echo "<meta http-equiv='refresh' content='0; url=http://www.google.com/search?hl=en&sugg ... off&q=$arg'>";

echo "<form action='http://www.mysite.com' name='googleform'>
<input name=q value='' size=40>
</form>";

My question:

This is functional but since it doesn't submit the google form the same way it won't parse things like calculator expressions or putting keywords of the search query in quotes.

Is there a way to use this META redirect scheme to forward the form to google the way my first form used to?
User avatar
Christopher
Site Administrator
Posts: 13596
Joined: Wed Aug 25, 2004 7:54 pm
Location: New York, NY, US

Re: Using <META> to redirect a form

Post by Christopher »

You might want to look at the PHP function header(). See the manual.
(#10850)
Post Reply