diesel55 Posted September 29, 2007 Share Posted September 29, 2007 I know nothing about PHP and need some help on how to accomplish the following. I have a web form which collects data and then does a POST action to call a PHP file which takes the data and sends it to an email address. This all works fine, but right now when I get the data in my email I get it back as follows: Date Submitted: 7/28/07 Name: Mark Jones I do not want the Labels with the : (I just want the data emailed) Basically what I need to be able to do is easily copy this data into an Excel file when I get it. With the labels include with the :, the data all gets put into the same column in Excel, so I need to remove the labels. I'm pretty sure I have to modify something in my code listed in Red below, but not sure what or if thats the only thing. PHP Code I'm using is below. Any help would be appreciated. <?php $to = "mark.jones@mycompany.com" ; $from = $_REQUEST['email'] ; $headers = "From: Web@mycompany.com"; $subject = "Web Inquiry"; $fields = array(); $fields{"date"} = "Date Submitted"; $fields{"name"} = "Name"; $fields{"referred"} = "Referred By"; $fields{"work"} = "Work Phone"; $fields{"cell"} = "Cell Phone"; $fields{"email"} = "Email Address"; $body = "We have received the following information:\n\n"; foreach($fields as $a => $b){ $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); } $headers2 = "From: noreply@YourCompany.com"; $subject2 = "Thank you for contacting us"; $autoreply = "Thank you for contacting us. Somebody will get back to you as soon as possible, usualy within 48 hours. If you have any more questions, please consult our website at www.giftofassurance.com"; if($from == '') {print "You have not entered an email, please go back and try again";} else { $send = mail($to, $subject, $body, $headers); if($send) {print "Information Submitted Successfully"; } else {print "We encountered an error sending your mail, please notify webmaster@giftofassurance.com"; } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/71175-php-array-email-data-in-csv-format/ Share on other sites More sharing options...
Barand Posted September 29, 2007 Share Posted September 29, 2007 Change $body .= sprintf("%20s: %s\n",$b,$_REQUEST[$a]); to $body .= sprintf("%s\n",$_REQUEST[$a]); if you want to omit the labels. Quote Link to comment https://forums.phpfreaks.com/topic/71175-php-array-email-data-in-csv-format/#findComment-358061 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.