Hi guys, relatively new to PHP - hoping someone can give me some advice.

I am trying to navigate to a certain page using a switch statement, ie the case that is chosen determines which page you are directed to.

The PHP code I have used reads as follows:

$TourName = $_REQUEST['TourName'];
switch ($TourName){
	case"Laos - Vientiane – Vangvieng (3days/2nights) Standard Class":
header("Location: http://www.holidaytime.net.au/html/payment/Vientiane - Vangvieng 3d 2n Standard Class.html");

	case"Laos - Vientiane – Vangvieng (3days/2nights) First Class":
header("Location: http://www.holidaytime.net.au/html/payment/Vientiane - Vangvieng 3d 2n First Class.html");

	case"Laos - Vientiane – Vangvieng (3days/2nights) Deluxe Class":
header("Location: http://www.holidaytime.net.au/html/payment/Vientiane - Vangvieng 3d 2n Deluxe Class.html");

	case"Laos - Luangprabang (3days/2nights) Standard Class":
header("Location: http://www.holidaytime.net.au/html/payment/Luangprabang 3ays 2 nights Standard Class.html");

	case "Laos - Luangprabang (3days/2nights) First Class":
header( "Location: http://www.holidaytime.net.au/html/payment/Luangprabang 3ays 2 nights First Class.html" );

	case"Laos - Luangprabang (3days/2nights) Deluxe Class":
header("Location: http://www.holidaytime.net.au/html/payment/Luangprabang 3ays 2 nights Deluxe Class.html");

	case"Laos - Luangprabang (3days/2nights) Standard Class":
header("Location: http://www.holidaytime.net.au/html/payment/Vientiane - Luangprabang 4d 3n - Standard Class.html");

	case"Laos - Luangprabang (3days/2nights) First Class":
header( "Location: http://www.holidaytime.net.au/html/payment/Vientiane - Luangprabang 4d 3n - First Class.html");

	case"Laos - Luangprabang (3days/2nights) Deluxe Class":
header("Location: http://www.holidaytime.net.au/html/payment/Vientiane - Luangprabang 4d 3n - Deluxe Class.html");

	case"Laos - Vientiane – Luangprabang (4days/3nights) Standard Class":
header( "Location: http://www.holidaytime.net.au/html/payment/Luangprabang 3ays 2 nights Standard Class.html" );

	case"Laos - Vientiane – Luangprabang (4days/3nights) First Class":
header("Location: http://www.holidaytime.net.au/html/payment/Luangprabang 3ays 2 nights First Class.html" );

	case"Laos - Vientiane – Luangprabang (4days/3nights) Deluxe Class":
header("Location: http://www.holidaytime.net.au/html/payment/Luangprabang 3ays 2 nights Deluxe Class.html");

	case "Vietnam - Hanoi - Saigon (14days/13nights) Deluxe":
header( "Location: http://www.holidaytime.net.au/html/payment/Vietnam HANOI- SAIGON (14 d 13 n) - Deluxe Class");

	case"Vietnam - Hanoi - Saigon (14days/13nights) Luxury":
header("Location: http://www.holidaytime.net.au/html/payment/Vietnam HANOI- SAIGON (14 d 13 n) - Luxury Class");

	case"Vietnam - Discovery (17days/16nights) Deluxe":
header("Location: http://www.holidaytime.net.au/html/payment/Vietnam Discovery (17 d 16 n) - Deluxe Class");

	case"Vietnam - Discovery (17days/16nights) Luxury":
header("Location: http://www.holidaytime.net.au/html/payment/Vietnam Discovery (17 d 16 n) - Luxury Class");

	case"Vietnam - Fascinating (7days/6nights) 2 Star":
header("Location: http://www.holidaytime.net.au/html/payment/Vietnam Fascinating Vietnam (7 Days 6 nights) - 2 Star.html");

	case"Vietnam - Fascinating (7days/6nights) 3 Star":
header("Location: http://www.holidaytime.net.au/html/payment/Vietnam Fascinating Vietnam (7 Days 6 nights) - 3 Star.html");

	case"Vietnam - Fascinating (7days/6nights) 4 Star":
header("Location: http://www.holidaytime.net.au/html/payment/Vietnam Fascinating Vietnam (7 Days 6 nights) - 4 Star.html");

	case"Vietnam - Fascinating (7days/6nights) 5 Star":
header("Location: http://www.holidaytime.net.au/html/payment/Vietnam Fascinating Vietnam (7 Days 6 nights) - 5 Star.html");

	case"Vietnam - Sapa Explorer 2 Day Trek (5days/4nights) Victoria":
header("Location: http://www.holidaytime.net.au/html/payment/Vietnam Sapa Explorer (5 Days) (2-Day Trek) - Victoria - Sapa.html");

	case"Vietnam - Sapa Explorer 2 Day Trek (5days/4nights) Chau Long":
header("Location: http://www.holidaytime.net.au/html/payment/Vietnam Sapa Explorer (5 Days) (2-Day Trek) - ChauLong - Sapa");

	case"Vietnam - The Scenic North (8days/7nights) Standard Guesthouses":
header("Location: http://www.holidaytime.net.au/html/payment/Vietnam 8 Days The Scenic North (8 Days 7 nights) - Standard Guesthouses.html");

	case"Vietnam - The Scenic North (8days/7nights) Van Hai Hotel":
header("Location: http://www.holidaytime.net.au/html/payment/Vietnam 8 Days The Scenic North (8 Days 7 nights) - Van Hai Hotel.html"); 

	case"Vietnam - The Scenic North (8days/7nights) Au Lac Resort":
header("Location: http://www.holidaytime.net.au/html/payment/Vietnam 8 Days The Scenic North (8 Days 7 nights) - Au Lac Resort.html");

	case"Vietnam - The Northern Loop (7days/6nights) ":
header("Location: http://www.holidaytime.net.au/html/payment/Vietnam 7 Days The Northern Loop - Standard.html");

	case"Vietnam - The Northern Loop (7days/6nights) ":
header("Location: http://www.holidaytime.net.au/html/payment/Vietnam 7 Days The Northern Loop - Voctoria Hotel Sapa");

	case"Cambodia - Discover Angkor-Siemreap (5days/4nights)":
header("Location: http://www.holidaytime.net.au/html/payment/Cambodia Tour - Discover Angkor-Siemreap 5 Days - Standard Class");

	case"Cambodia - Angkor Wat Stopover (2days)":
header("Location: http://www.holidaytime.net.au/html/payment/Cambodia Tour - Angkor Wat Stopover 2 days - Standard Class.html");

	case"Cambodia - Phnom Penh - Angkor (7days)":
header("Location: http://www.holidaytime.net.au/html/payment/Cambodia Tour - Phnom Penh - Angkor 7 days - Standard Class");

	case"Overland - Best of Laos and Cambodia (16days)":
header("Location: http://www.holidaytime.net.au/html/payment/Overland - Best of Laos and Cambodia 16 days.html");

	case"Overland - Mekong Speed Boat Adventure (8days)":
header("Location: http://www.holidaytime.net.au/html/payment/Overland - Mekong Speed Boat Adventure 8 days.html");
}

$TourName is submitted by a form in a previous page. I've made sure the values from this page are the same as the case so I don't think that is causing the problem.

I get many errors... this is what the output reads:

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 48

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 51

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 54

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 57

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 60

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 63

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 66

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 69

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 72

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 75

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 78

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 81

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 84

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 87

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 90

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 93

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 96

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 99

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 102

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 105

Warning: Cannot modify header information - headers already sent by (output started at /home/holidayt/public_html/html/checkout.php:11) in /home/holidayt/public_html/html/checkout.php on line 108

It's probably just my syntax... any help would be greatly appreciated.

Thank you for reading.

header() function should come at the top of the page ... there should not be any echo or any output before this function call; like for sessions().

so if you really need to redirect from in between the page please use js function as

function redirect_to(url)
{
           document.location=url;
}

or if you need something as permanent redirection then you can use redirect through .htaccess

Please note: Google is your friend for .htaccess

You are outputting something on line 11 of checkout.php . As naju has mentioned, either call header function before outputting anything or comment line 11 !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.