zero-perfoliate
zero-perfoliate

Author Topic: Problem with Headers  (Read 396 times)

Offline sbeckstrand

  • New PHP Members
  • Posts: 1
  • Karma: +0/-0
Problem with Headers
« on: June 01, 2010, 03:43:00 AM »
I have been working on the script below for a number of hours.  It is called form a HTML form.  The email send works fine, but when I attempt to load a Thank you page, I get the following error:  Warning: Cannot modify header information - headers already sent by (output started at /home/content/l/a/r/larryrmoses/html/Alumni/contact.php:1) in /home/content/l/a/r/larryrmoses/html/Alumni/contact.php on line 18

I have checked for whitespace in the file.  I have added the ob_start and flush functions, but I still get the error.  Any additional ideas or solutions would be appreciated.

PHP Code:
<?php ob_start();
$subject = "Alumni Information";
$fields = array();
$fields{"FirstName"} = "First Name";
$fields{"LastName"} = "Last Name";
$fields{"Email"} = "Email";
$fields{"Phone"} = "Phone";
$fields{"MailingAddress"} = "Address";
$fields{"City"} = "City";
$fields{"State"} = "State";
$fields{"ZipCode"} = "Zip Code";
$fields{"Information"} = "Information";
$body = "We have received the following information:\n\n";
foreach($fields as $a => $b){
  $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]);}
$send = mail("info@desertvalleyacademy.org", $subject, $body, "Web Site");
if($send){
  header("Location: http://www.desertvalleyacademy.org/Alumni/Thanks.html");}
ob_end_flush(); ?>

Offline jimmyrain77

  • New PHP Members
  • Posts: 2
  • Karma: +0/-0
Re: Problem with Headers
« Reply #1 on: April 10, 2011, 11:15:10 PM »
If you use wp_redirect() to airt to added web diplomat then you might hit the "headers already sent" failure. For me it was in pluggable.php, but I didn't appear suchlike messing near with this. For a advantage, pluggable.php had no end "?>" and solutions talked nearly bad characters after that.

 

zero-perfoliate