brmcdani Posted January 1, 2010 Share Posted January 1, 2010 I am getting the following error message: Cannot modify header information - headers already sent by (output started at /home/content/s/a/g/sagates/html/contact.php:1) in /home/content/s/a/g/sagates/html/contact.php on line 17 Here is my code: <?php ob_start(); $name = $_REQUEST['name']; $phone = $_REQUEST['phone']; $email = $_REQUEST['email']; $pref = $_REQUEST['pref']; $type = $_REQUEST['type']; $kind = $_REQUEST['kind']; $message = $_REQUEST['message']; $body = "Name: $name \nPhone Number: $phone \nEmail: $email \nContact Preference: $pref \nJob Type: $type \nInterested In: $kind \nDescription: $message \n\n"; mail( "brett.mcdaniel@ttu.edu", "Contact Request", $body); header("Location: thankyou.htm"); ?> I think I need an ending ob_ statement just not sure which one. Can someone please help me out??? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/186833-cannot-modify-header-info/ Share on other sites More sharing options...
premiso Posted January 1, 2010 Share Posted January 1, 2010 The <?php must be the very first character of the file. <?php Is not valid, that will cause a header message, as will: <?php The correct way is: <?php Notice no extra spaces etc. If it is not done that way correct it and it should work (without the ob_start / flush methods). Quote Link to comment https://forums.phpfreaks.com/topic/186833-cannot-modify-header-info/#findComment-986641 Share on other sites More sharing options...
brmcdani Posted January 1, 2010 Author Share Posted January 1, 2010 Ok there are no extra spaces anywhere with the starting php line now I have this and am getting a header error message on line 17 which is the beginning of the header line. <?php $name = $_REQUEST['name']; $phone = $_REQUEST['phone']; $email = $_REQUEST['email']; $pref = $_REQUEST['pref']; $type = $_REQUEST['type']; $kind = $_REQUEST['kind']; $message = $_REQUEST['message']; $body = "Name: $name \nPhone Number: $phone \nEmail: $email \nContact Preference: $pref \nJob Type: $type \nInterested In: $kind \nDescription: $message \n\n"; mail("brett.mcdaniel@ttu.edu", "Contact Request", $body); header("Location: thankyou.htm"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/186833-cannot-modify-header-info/#findComment-986645 Share on other sites More sharing options...
premiso Posted January 1, 2010 Share Posted January 1, 2010 It could be how the file is being saved. Try opening a new page in notepad and pasting that code in there making sure there are no extra lines at the beginning and saving the file and see if it works then. As a BOF (beginning of file, at least I think that is what it is called) marker may have been added by your editor. Quote Link to comment https://forums.phpfreaks.com/topic/186833-cannot-modify-header-info/#findComment-986646 Share on other sites More sharing options...
brmcdani Posted January 1, 2010 Author Share Posted January 1, 2010 Still doesn't work! I dont know what else to try. This has to be done tonight and ready to go for a client tomorrow. Quote Link to comment https://forums.phpfreaks.com/topic/186833-cannot-modify-header-info/#findComment-986648 Share on other sites More sharing options...
premiso Posted January 1, 2010 Share Posted January 1, 2010 The other option is, since it seems the header is difficult to diagnose for you is use a meta refresh. // header("Location: thankyou.htm"); ?> <meta http-equiv="refresh" content="0;url=thankyou.htm"> Should work to redirect. Quote Link to comment https://forums.phpfreaks.com/topic/186833-cannot-modify-header-info/#findComment-986651 Share on other sites More sharing options...
brmcdani Posted January 1, 2010 Author Share Posted January 1, 2010 Great this worked. Thanks for your help happy new year! Quote Link to comment https://forums.phpfreaks.com/topic/186833-cannot-modify-header-info/#findComment-986654 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.