Jump to content

Missing something obvious with headers being sent


damianjames

Recommended Posts

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@address.com\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!

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.