damianjames Posted November 2, 2010 Share Posted November 2, 2010 Hi all - It's gotta be something obvious, but I can't for the life of me how I'm sending output in this file before I send a header redirect. Can anyone see it? <?php //Initialize securimage captcha session_start(); require_once('dbconnect.php'); // initialize db connection to populate email address include_once('../securimage/securimage.php'); $language = $_POST['lang']; include($language . ".php"); //Load language file for feedback. TODO: Maintain separate file for this so the script doesn't need to load so many unused variables? $securimage = new Securimage(); if ($securimage->check($_POST['captcha_code']) == false) { die($contact_bad_captcha); } // pump post vars into local vars and clean them up, assign to session to display on contact completion function lang($language) { //Give hidden post var for language a human name switch ($language) { case en: return "English"; break; case es: return "Español"; break; default: return "Español"; } } $reason = htmlentities($_POST['reason'], ENT_QUOTES); $name = htmlentities($_POST['name'], ENT_QUOTES); $email = htmlentities($_POST['email'], ENT_QUOTES); $phone = htmlentities($_POST['phone'], ENT_QUOTES); $cell = htmlentities($_POST['cell'], ENT_QUOTES); $method = htmlentities($_POST['method'], ENT_QUOTES); $comments = htmlentities($_POST['comments'], ENT_QUOTES); $lang = lang($language); // Query for email addresses $query = "SELECT `description`,`email` FROM contact WHERE `code` = \"" . $reason . "\" AND `language` = \"" . $language . "\""; $result = mysql_query($query); while ($row = mysql_fetch_assoc($result)) { $to = $row['email']; $reason = $row['description']; } $subject = "ELP Contact Form Submission From " . $name; $_SESSION['name'] = $name; $_SESSION['email'] = $email; $_SESSION['phone'] = $phone; $_SESSION['cell'] = $cell; $_SESSION['method'] = $method; $_SESSION['comments'] = $comments; // Build the mail object $header = "From: " . $email . "\r\n"; $header .= "Reply-To: " . $email . "\r\n"; $header .= "Bcc: [email protected]\r\n"; $header .= "Content-type: text/html; charset=iso-8859-1\r\n"; $message = "Reason: " . $reason . "<br>"; $message .= "Name: " . $name . "<br>"; $message .= "Email: " . $email . "<br>"; $message .= "Phone: " . $phone . "<br>"; $message .= "Cell: " . $cell . "<br>"; $message .= "Method to contact: " . $method . "<br>"; $message .= "Comments/Questions: " . nl2br($comments) . "<br>"; $message .= "Language: " . lang($language); // Send it after checking that variables are set correctly if (isset($name) && isset($email) && isset($method) && isset($comments) && isset($header) && isset($message)) { mail($to, $subject, $message, $header); header("Location: ../contactcomplete.php?lang=" . $language); // Forward to completion page which displays what was sent } else { echo $contact_general_error; //Unknown error } ?> Warning: Cannot modify header information - headers already sent by (output started at /home1/supresen/public_html/configs/es.php:1) in /home1/supresen/public_html/configs/email.php on line 67 Thanks for the help! Quote Link to comment https://forums.phpfreaks.com/topic/217604-missing-something-obvious-with-headers-being-sent/ Share on other sites More sharing options...
PFMaBiSmAd Posted November 2, 2010 Share Posted November 2, 2010 If you have nothing in the es.php file on line one that produces output, then the problem is likely the BOM (Byte Order Mark) characters that your editor places at the start of a UTF-8/16 encoded file when it saves your work. If you must save your file as UTF-8/16 encoded, save it without the BOM or save it as an ANSI encoded file. Quote Link to comment https://forums.phpfreaks.com/topic/217604-missing-something-obvious-with-headers-being-sent/#findComment-1129689 Share on other sites More sharing options...
damianjames Posted November 3, 2010 Author Share Posted November 3, 2010 That was it! Thanks so much... I should read what PHP tries to tell me a little closer, since I've been searching high and low within email.php instead of the language file where it told me to look! Thanks again! Quote Link to comment https://forums.phpfreaks.com/topic/217604-missing-something-obvious-with-headers-being-sent/#findComment-1129720 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.