473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Form email (php) to spreadsheet

nomad
664 Expert 512MB
I have a form email created in HTML and php and I want to have the info populated to:
1. an email (I know how to do this part)
2. to a spreadsheet which updates without losing the previous data (ie much like google forms but I don't want to use them because of the logos and copy write info)

If anyone can help me that could be great the easier the better,

Thanks
damon
Feb 14 '14 #1
3 1226
Luuk
1,047 Expert 1GB
Why not simply write info to a csv file?
It is very simple to read those in a spreadhseet.
Feb 15 '14 #2
nomad
664 Expert 512MB
Thanks Luuk

I need some help I wrote some code but I need the 3 fields created instead of one when I open the data in excel
Here is my info
Html
Expand|Select|Wrap|Line Numbers
  1. <form name="contactform" method="post" action="contact_us_how_can1.php">
  2.  
  3.   <section class="form">
  4.     <textarea name="comments" cols="110" rows="6" class="col_form_bold">How can we help you?</textarea>
  5.  </section>
  6.  
  7.    <section class="col_form"> 
  8.  Your Name: <input name="Your_name" type="text" class="col_form_bold1" value="Full Name" size="35"  />
  9.   </section>
  10.  
  11.    <section class="col_form"> 
  12.  Your email: 
  13.    <input name="email" type="text" class="col_form_bold1" value="email@example" size="32"  />
  14.    </section>
  15.    <section class="col_form">  
  16.      <input type="submit" class="message"    value="   Send Message   " />
  17.      </section>
  18.  </form>
  19.  
PHP code
Expand|Select|Wrap|Line Numbers
  1.  <?
  2.  
  3.  
  4. if(isset($_POST['email'])) {
  5.  
  6.     // EDIT THE 2 LINES BELOW AS REQUIRED
  7.     $email_to = "dwong@lightlaboratory.com" ;
  8.     $email_subject = "How can I help you";
  9.  
  10.  
  11.  
  12.     if(!isset($_POST['comments']) ||
  13.         !isset($_POST['Your_name']) ||
  14.         !isset($_POST['email'])) //{
  15.         died('We are sorry, but there appears to be a problem with the form you submitted.');      
  16.    // }
  17.    $del = "\t";
  18.     $data[1] = $_POST['comments'];
  19.     $data[2] = $_POST['Your_name'];
  20.     $data[3] = $_POST['email']; 
  21.     $file = fopen("data.csv", "a");
  22.     $data = "\r\n".implode($del, $data);
  23.     fwrite($file, $data);
  24.     fclose($file); 
  25.  
  26.  
  27.  
  28.     $comments = $_POST['comments']; 
  29.     $Your_name = $_POST['Your_name']; 
  30.     $email = $_POST['email']; 
  31.  
  32.  
  33.  
  34.     $email_message = "How can I help you.\n\n";
  35.  
  36.     function clean_string($string) {
  37.       $bad = array("content-type","bcc:","to:","cc:","href");
  38.       return str_replace($bad,"",$string);
  39.     }
  40.     $email_message .= "Comments:    ".clean_string($comments)."\n";
  41.     $email_message .= "Name:    ".clean_string($Your_name)."\n";
  42.     $email_message .= "Email:      ".clean_string($email)."\n";
  43.  
  44.  
  45. // create email headers
  46. $headers = 'From: '.$email_from."\r\n".
  47. 'Reply-To: '.$email_from."\r\n" .
  48. 'X-Mailer: PHP/' . phpversion();
  49. @mail($email_to, $email_subject, $email_message, $headers); 
  50. ?>
  51.  
  52. <!-- include your own success html here -->
  53.  
  54. <p>Your response has been recorded and one of our friendly, <br>
  55. support staff  member will answer your questions and brighten your day.<br>
  56. Have a great day!</p>
  57. <?php
  58. }
  59. ?>
  60.  
  61.  
  62. Any help would be great. 
  63. damon
  64.  
Feb 17 '14 #3
Luuk
1,047 Expert 1GB
maybe:
You have to tell excel to use a tab as separator?

But if that does not solve the problem, i would like to know what you see in this 1 kolom you are getting.

i.e.
Expand|Select|Wrap|Line Numbers
  1. $data[1] = "comments";
  2.     $data[2] = "Your_name";
  3.     $data[3] = "email"; print implode(";",$data);
prints:
Expand|Select|Wrap|Line Numbers
  1. comments;Your_name;email
This should lead to 3 columns in excel if ";" is set as separator.
Feb 18 '14 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: bawar | last post by:
Hellow, I don't seem to be able to send trough the variable 'language' from my form to the php-variable $language that I want to use in my session... I first tried in the form with a drop down...
4
by: Scott Castillo | last post by:
Does anybody know how to auto-submit a form in PHP without Javascript? For instance, submit form variables to self, validate the data in PHP on same page, then, if no errors, auto-submit the data...
19
by: gsb | last post by:
HOW TO: Submit a form to PHP with no return? I need to submit a form for file upload to a PHP script but do not want anything returned. That is the TARGET for the form should be like a null...
2
by: vishal | last post by:
hello friends i have one php script which generates html page containing form. what i want is submit this form using php script. pls give me some idea that how can i submit form using php...
7
TheMadMidget
by: TheMadMidget | last post by:
I am trying to send a form through PHP. I want it to act the same as a regular form with a post method. I have used cURL before to just send the information, but I am trying to make it follow it. I...
0
by: mamoon | last post by:
hi all, i am facing a serious problem in running JDBC programm in Apache server environment. Background Information- 1, OS: Enterprise Linux4 running Apache2 2. pgsql8.2 3.JDBC driver:...
10
by: phopman | last post by:
Hi there! Thanks for all the help so far. When my boss said I should be up to date as soon as possible, he meant last week. So I got a good rollicking when I came to work. Nice way to start my...
4
psycho802
by: psycho802 | last post by:
hi guys! i'm newbie of this forum, can i ask for some help about submitting a form using php... tnx!
7
by: lostcracker | last post by:
cracker as in cookie.. its a long story.. Anyways, so glad I found this place.. should be fun! trying to submit a form with php script. here is the form <form name="userdata_template_form"...
1
by: elhelow | last post by:
How to Post data from c# windows app form to php,data found in my form and i want to post it, such in php var=name_web and it's value ="bobo", how i can do this?
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.