Jump to content

PHP Array Email Data in CSV Format


diesel55

Recommended Posts

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"; }

}

?>

 

 

Link to comment
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.