Howdy...
I have a survey form that I get the data and send the result in an email to the owner... Everything works fine, but I'd like to add a TAB, but somehow it is not working quite right...
This will be the simplified version...
<?
// testTab.php
$str1 = "Question 1) Blah Blah...";
$str2 = "Answer A) Blah Blah...";
$CR = "<BR>";
$TAB = "\t";
$output = $str1 . $CR . $TAB . $str2;
echo($output);
?>
I am expecting this to output like this...
Question 1) Blah Blah...
Answer A) Blah Blah...
but I get this instead...
Question 1) Blah Blah...
Answer A) Blah Blah...
This is the whole script...
<?php
// surveyMail.php
$message = "";
$headers = "";
$output = "";
// $CR = "\r";
$CR = "<BR>";
$TAB = "\t";
// $TAB = chr(9);
$date = date("m/d/Y H:i:s");
import_request_variables('P');
$headers .= "From: New_Survey_Result\n";
$headers .= "Reply-To: $email\n";
$headers .= "X-Mailer: PHP/\n";
$headers .= "MIME-Version: 1.0\n";
$headers .= "Content-type: text/html; charset=iso-8859-1";
$message .= "------------------------------" . $CR;
$message .= "Personal Information" . $CR;
$message .= "------------------------------" . $CR;
$message .= "Name : $name" . $CR;
$message .= "Email : $email" . $CR;
$message .= "Age : $age" . $CR;
$message .= "------------------------------" . $CR . $CR;
$message .= "------------------------------" . $CR;
for ($i = 1; $i <= 9; $i++)
{
$message .= stripslashes(${"q" . $i}) . $CR . $TAB . stripslashes(${"a" . $i}) . $CR . $CR;
}
$message .= "------------------------------" . $CR;
$message .= $date .$CR;
$message .= "------------------------------" . $CR;
$send = mail($owner, "New Survey Result by $name", $message, $headers);
if ($send == true)
{
$output = "message=$message&emailSent=true";
}
else
{
$output = "message=$message&emailSent=false";
}
echo($output);
$output .= "\n\n\n";
$FileName = "./sentEmail.txt";
$FilePointer = fopen($FileName, "a+");
fwrite ($FilePointer, $output);
fclose ($FilePointer);
?>
As you can see I am appending each result to the text file called 'sentEmail.txt'... The thing is that the text file has the desired format... It is just now showing up right within the browser...
If I change this line...
$headers .= "Content-type: text/[b]html[/b]; charset=iso-8859-1";
to be this, it does show me the correct TAB character...
$headers .= "Content-type: text/[b]plain[/b]; charset=iso-8859-1";
But with the 'plain', the email does not show up correctly... The output that I have adding within the for loop do not show up correctly if I set it to 'plain', which I have no idea why, but with 'html' I get to see the correct output without the TAB character...
Anybody can shed some light on me???
Thank you for your time...