pixeltrace Posted October 17, 2007 Share Posted October 17, 2007 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 More sharing options...
Barand Posted October 17, 2007 Share Posted October 17, 2007 Does quoting the data help? $data = "\"$name\",\"$email\",\"$phone\",\"$organization\",\"$designation\",\"$date\"$cr"; Link to comment https://forums.phpfreaks.com/topic/73612-need-help-in-csv-saving/#findComment-371473 Share on other sites More sharing options...
sasa Posted October 17, 2007 Share Posted October 17, 2007 insert before line $data = $name . ',' . $email . ',' . $phone . ',' . $organization . ',' . $designation . ',' . $enquiry . ',' . $date . $cr; line $enquiry = nl2br($enquiry); Link to comment https://forums.phpfreaks.com/topic/73612-need-help-in-csv-saving/#findComment-371480 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.