Redirecting using 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
roondog
Forum Newbie
Posts: 18
Joined: Sun Jul 22, 2007 11:56 am

Redirecting using a form

Post by roondog »

I have a simple form with a drop down menu to choose a page to go to.
the form then uses this

Code: Select all

<?php
if (isset($_POST['submitted'])) {
	if ($_POST['gallery'] == 'fashion') 
	{
		header ('Location:http://localhost/model/fashion.php');
	} 
	elseif ($_POST['gallery'] == 'glamour')
	{
		header ('Location:http://localhost/model/glamour.php');
	}
	elseif ($_POST['gallery'] == 'shows')
	{
		header ('Location:http://localhost/model/shows.php');
	}
	elseif ($_POST['gallery'] == 'tearsheets');
	{
		header ('Location:http://localhost/model/tearsheets.php');
	}
	
}
	?>
But nothing seems to be happening. Any suggestions please.
User avatar
s.dot
Tranquility In Moderation
Posts: 5001
Joined: Sun Feb 06, 2005 7:18 pm
Location: Indiana

Post by s.dot »

Firstly, you need exit; calls after your header call.
Secondly, var_dump($_POST['submitted']); and var_dump($_POST['gallery']); to see if the values you are expecting are getting across.
Set Search Time - A google chrome extension. When you search only results from the past year (or set time period) are displayed. Helps tremendously when using new technologies to avoid outdated results.
roondog
Forum Newbie
Posts: 18
Joined: Sun Jul 22, 2007 11:56 am

Post by roondog »

Thanks, it works now. I hadn't finished the form so it wasn't working.
Post Reply