danjapro Posted September 23, 2011 Share Posted September 23, 2011 My Error Output is this: Warning: Cannot modify header information - headers already sent by (output started at city-search.php:1) in city-search.php on line 65 What I'm I missing in the code, I can't seem to get these. It works excellent in Localhost, but in production. Error above. <?php // MG CREATED THIS SIMPLE REGISTRATION PHP FOR THAT GOES TO ONE SPECIFIC USER. // WILL TEST FORM REGSITRATION NG 07-2011 //If the form is submitted if(isset($_POST['submit'])) { //Check to make sure that the name field is not empty if(trim($_POST['name']) == '') { $hasError = true; } else { $name = trim($_POST['name']); } //Check to make sure that the subject field is not empty if(trim($_POST['subject']) == '') { $hasError = true; } else { $subject = trim($_POST['subject']); } //Check to make sure sure that a valid email address is submitted if(trim($_POST['email']) == '') { $hasError = true; } else if (!eregi("^[A-Z0-9._%-]+@[A-Z0-9._%-]+\.[A-Z]{2,4}$", trim($_POST['email']))) { $hasError = true; } else { $email = trim($_POST['email']); } //Check to make sure comments were entered if(trim($_POST['message']) == '') { //$hasError = true; $comments == 'Have No Friends'; } else { if(function_exists('stripslashes')) { $comments = stripslashes(trim($_POST['message'])); } else { $comments = trim($_POST['message']); } } //If there is no error, send the email if(!isset($hasError)) { //$emailTo = '[email protected]'; //$emailTo = '[email protected]'; $emailTo = '[email protected]'; //$emailBcc = '[email protected]'; //$emailBcc = '[email protected]'; //$emailBcc = '[email protected]'; //Put your own email address here $body = "Location: $name \n\nEmail: $email \n\nShushMeDeals Sign-up Info:\n $comments"; // To send HTML mail, the Content-type header must be set $headers = 'From: ShushMeDeals.com City Location sign-up - '.$name.'' . "\r\n" . 'Reply-To: ' . $email . "\r\n" .'Bcc: [email protected]'; //$headers .= 'Cc: [email protected]' . "\r\n"; //$headers .= 'Bcc: [email protected]' . "\r\n"; mail($emailTo, $subject, $body, $headers); $emailSent = true; if($emailSent = true) { setcookie("location", $name); //echo '<script type="text/javascript"> // window.location = "index.php?option=com_enmasse&controller=deal&task=today&locationName='.$name.'" // </script>'; } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/247683-header-location-issue-small-piece-of-code-can-anyone-take-a-look/ Share on other sites More sharing options...
btherl Posted September 23, 2011 Share Posted September 23, 2011 Have you read this thread? http://www.phpfreaks.com/forums/index.php?topic=37442.0 According to the error the output was started on the first line of your script. Quote Link to comment https://forums.phpfreaks.com/topic/247683-header-location-issue-small-piece-of-code-can-anyone-take-a-look/#findComment-1271909 Share on other sites More sharing options...
voip03 Posted September 23, 2011 Share Posted September 23, 2011 If you like try this code (place it top of your code), let me know the result. /* "Warning: Cannot modify header information - headers already sent by " To avoid the header error , give value zero to $mosConfig_locale_debug = 0; $mosConfig_locale_use_gettext = 0; */ $mosConfig_locale_debug = 0; $mosConfig_locale_use_gettext = 0; ob_start(); /* Quote Link to comment https://forums.phpfreaks.com/topic/247683-header-location-issue-small-piece-of-code-can-anyone-take-a-look/#findComment-1271935 Share on other sites More sharing options...
danjapro Posted September 23, 2011 Author Share Posted September 23, 2011 Tried teh header, it didnot really help. Gave another t_variable error becasue of the last /* you had in code. Once removed same error, with header modify issue. Quote Link to comment https://forums.phpfreaks.com/topic/247683-header-location-issue-small-piece-of-code-can-anyone-take-a-look/#findComment-1271940 Share on other sites More sharing options...
voip03 Posted September 23, 2011 Share Posted September 23, 2011 Your code is work fine. Are you starting the code from top and no space? Quote Link to comment https://forums.phpfreaks.com/topic/247683-header-location-issue-small-piece-of-code-can-anyone-take-a-look/#findComment-1271971 Share on other sites More sharing options...
danjapro Posted September 24, 2011 Author Share Posted September 24, 2011 There are no space at the top of php script page at all. It works fine in development, but as usually. It does not work in production, produces that header modfiy issue. It racking my little brain..... This is my from action, woud this be the direct cause... <form action="<?php echo $_SERVER['PHP_SELF']; ?>" id="submitLocation" name="submitLocation" method="post" > Quote Link to comment https://forums.phpfreaks.com/topic/247683-header-location-issue-small-piece-of-code-can-anyone-take-a-look/#findComment-1272224 Share on other sites More sharing options...
Pikachu2000 Posted September 24, 2011 Share Posted September 24, 2011 The first thing I'd try is to open the script in my editor, and resave it in UTF-8, making sure it is saved without BOM (byte order mark). If that doesn't change anything, say so. Quote Link to comment https://forums.phpfreaks.com/topic/247683-header-location-issue-small-piece-of-code-can-anyone-take-a-look/#findComment-1272228 Share on other sites More sharing options...
danjapro Posted September 24, 2011 Author Share Posted September 24, 2011 I am getting stoked by this little bit of code messing me up. What do you mean by resave utf-8 output. Different file extension. Save a ttp file then resave as php file? Not sure what you meant here? Quote Link to comment https://forums.phpfreaks.com/topic/247683-header-location-issue-small-piece-of-code-can-anyone-take-a-look/#findComment-1272263 Share on other sites More sharing options...
Pikachu2000 Posted September 24, 2011 Share Posted September 24, 2011 No, your editor should have options as to which type of character encoding to use when saving files. The encoding should be UTF-8 and it should save the file without BOM. More info: http://www.phpfreaks.com/forums/index.php?topic=37442.msg1385483#msg1385483 Quote Link to comment https://forums.phpfreaks.com/topic/247683-header-location-issue-small-piece-of-code-can-anyone-take-a-look/#findComment-1272265 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.