Link to home
Start Free TrialLog in
Avatar of breeze351
breeze351

asked on

Problem with if statement not working correctly.

I have some code that looks like this:
	$work = $_SESSION['Add_Name_1'].$_SESSION['Add_Name_2'].$_SESSION['Add_Name_3'];
	echo "work = ".$work;
	if ($work == "NNN")
	{
		Header ("Location:Update_Space.php");
		exit;
	}

Open in new window

I've checked the vars, if one is checked it works.  But if none of the vars are checked , I get the following error:

work = NNN
Warning: Cannot modify header information - headers already sent by (output started at /home/langsyst/public_html/seabreezesoftware/Retail/Space_Contact_Update.php:27) in /home/langsyst/public_html/seabreezesoftware/Retail/Space_Contact_Update.php on line 144

Let me know if you need more info.
Avatar of Dave Baldwin
Dave Baldwin
Flag of United States of America image

'headers' must be sent before any content is sent.  Your code shows an 'echo' right before your 'if'.  That will never work.  If you need the 'echo' simply move it to after the 'if' where the 'header' is.
	$work = $_SESSION['Add_Name_1'].$_SESSION['Add_Name_2'].$_SESSION['Add_Name_3'];
	if ($work == "NNN")
	{
		Header ("Location:Update_Space.php");
		exit;
	}
	echo "work = ".$work;

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Swatantra Bhargava
Swatantra Bhargava
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of breeze351
breeze351

ASKER

Found it,  It wasn't the code but where the <head> was located