Jump to content

need help in csv saving


pixeltrace

Recommended Posts

hi,

 

i have a form and it saves all logs into the enquiry.csv

everything is working fine except that for the message

text area, when i type something with spaces

example

test1
test2
test2

 

the output in my csv is being moved into other cells

below is my current code

<?
/* code for the sending of mail and saving to csv start */
if (isset($_POST['Submit'])) {
$salutation = $_POST['salutation'];
$name = $_POST['name'] ;
$email = $_POST['email'] ;
$phone = $_POST['phone'] ;
$organization = $_POST['organization'] ;
$designation = $_POST['designation'] ;
$enquiry = $_POST['message'] ;

$msg = "A General Enquiry was sent from Capitaland ILEC website \n"
."Name: ".$name."\n"
."Email Address: ".$email."\n"
."Contact No: ".$phone."\n"
."Organization: ".$organization."\n"
."Designation: ".$designation."\n"
."Enquiry: ".$enquiry;

//mail the above data
// to send HTML mail, the Content-type header must be set
//$to ='[email protected]';
$to ='[email protected]';
$subject = 'CapitaLand ILEC - General Enquiry';
$message = $msg;


$headers = 'From: ' .$email. "\r\n";
$headers .= 'Bcc: [email protected]' . "\r\n";

// Mail it
mail($to, $subject, $message, $headers);

  
$cr = "\n";
$date=date('Y-M-d G:i:s');


//write data to csv 
$data = $name . ',' . $email . ',' . $phone . ',' . $organization . ',' . $designation . ',' . $enquiry . ',' . $date . $cr;
$filename = 'logs/enquirylog.csv'; 
$fp = fopen($filename,"a"); // $fp is now the file pointer to file $filename

if($fp){
      fwrite($fp,$data); // Write information to the file
      fclose($fp);  // Close the file
} 
}
/* code for the sending of mail and saving to csv end */
?>

 

hope you could help me with this.

 

thanks!

Link to comment
https://forums.phpfreaks.com/topic/73612-need-help-in-csv-saving/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.