Page 1 of 1

processing forms

Posted: Sat Aug 07, 2004 5:15 pm
by Daisy Cutter
I have a form like this:

Code: Select all

<form method="get" name="url" action="get.php">
<select name="url">
<option value="contact_me.php">contact</option>
<option value="blog">blog</option>
<option value="forum">forum</option>
</select>
<input type="submit" value="go">
And I need to make get.php redirect to the selected page. This is what I have so far:

Code: Select all

<?php
$get = $_POST['url']
header("Location: "$get"");
exit;
?>
But that doesn't work. Please help.

Thanks!

Posted: Sat Aug 07, 2004 5:21 pm
by timvw
1-) You say in your form method GET -> variables in get.php will be in $_GET and not in $_POST ;)


2-) Redirection with a header is not RFC compliant if you use a relative URL like contact.php. It should be http://foo/contact.php

Posted: Sat Aug 07, 2004 5:47 pm
by Daisy Cutter
You're tip led to a fix! Thank you, all I had to do was change it from $_POST['url] to $url, and it worked fine.

Posted: Sat Aug 07, 2004 5:48 pm
by feyd
8O register globals are on? yikes.

Posted: Sat Aug 07, 2004 6:50 pm
by Daisy Cutter
Is register globals a security risk? It's not my own server, I'm hosted by dreamhost.

Posted: Sat Aug 07, 2004 7:17 pm
by feyd
generally yeah.. it's been defaulted to off for the last, what 2 years now.. I think.. since around 4.2.0

Posted: Sat Aug 07, 2004 11:34 pm
by d3ad1ysp0rk

Code: Select all

<?php
header("Location: " . $_GET['url']);
?>
That should work.