processing forms

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
Daisy Cutter
Forum Commoner
Posts: 75
Joined: Sun Aug 01, 2004 9:51 am

processing forms

Post 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!
timvw
DevNet Master
Posts: 4897
Joined: Mon Jan 19, 2004 11:11 pm
Location: Leuven, Belgium

Post 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
Daisy Cutter
Forum Commoner
Posts: 75
Joined: Sun Aug 01, 2004 9:51 am

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

8O register globals are on? yikes.
Daisy Cutter
Forum Commoner
Posts: 75
Joined: Sun Aug 01, 2004 9:51 am

Post by Daisy Cutter »

Is register globals a security risk? It's not my own server, I'm hosted by dreamhost.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

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 »

Code: Select all

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