Jump to content

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 ='redha.eepsooni@resonance.com.sg';
$to ='raymund.evangelista@resonance.com.sg';
$subject = 'CapitaLand ILEC - General Enquiry';
$message = $msg;


$headers = 'From: ' .$email. "\r\n";
$headers .= 'Bcc: erica.sim@resonance.com.sg' . "\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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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