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
Daisy Cutter
Forum Commoner
Posts: 75 Joined: Sun Aug 01, 2004 9:51 am
Post
by Daisy Cutter » Sat Aug 07, 2004 5:15 pm
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!
timvw
DevNet Master
Posts: 4897 Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium
Post
by timvw » Sat Aug 07, 2004 5:21 pm
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
Daisy Cutter
Forum Commoner
Posts: 75 Joined: Sun Aug 01, 2004 9:51 am
Post
by Daisy Cutter » Sat Aug 07, 2004 5:47 pm
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Aug 07, 2004 5:48 pm
register globals are on? yikes.
Daisy Cutter
Forum Commoner
Posts: 75 Joined: Sun Aug 01, 2004 9:51 am
Post
by Daisy Cutter » Sat Aug 07, 2004 6:50 pm
Is register globals a security risk? It's not my own server, I'm hosted by dreamhost.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Sat Aug 07, 2004 7:17 pm
generally yeah.. it's been defaulted to off for the last, what 2 years now.. I think.. since around 4.2.0
d3ad1ysp0rk
Forum Donator
Posts: 1661 Joined: Mon Oct 20, 2003 8:31 pm
Location: Maine, USA
Post
by d3ad1ysp0rk » Sat Aug 07, 2004 11:34 pm
Code: Select all
<?php
header("Location: " . $_GET['url']);
?>
That should work.