ArtsAutosBooksBusinessEducationEntertainmentFamilyFashionFoodGamesGenderHealthHolidaysHomeHubPagesPersonal FinancePetsPoliticsReligionSportsTechnologyTravel
  • »
  • Technology»
  • Internet & the Web

PHP form inserts data into CSV file

Updated on January 17, 2014

Today we are going to use a .csv (comma separated values) file to store values from an online PHP web form.

A .csv file is a file that you can create easily with Microsoft Excel (further knowledge is beyond the scope of this tutorial).

Okay, first off we will use the multi-purpose page technique from Build Database Driven Website Using PHP and MySql.

We aren't using a database, we are going to use Excel in .csv form to store the form data.

Why do this when you can use a database?

  1. Data is portable
  2. Data is readily readable by MS office
  3. Data is web ready
  4. Web hosting is simple, FTP and done.

Since my server location is offline, email me for the src code, sorry.

First we create a simple form:

<form id="form1" name="form1" method="post" action="<?=$_SERVER['PHP_SELF'];?>">
<table class="formatTblClass">
<tr>
<th colspan="6"><?=$message;?></th>
</tr>
<tr>
<td width="68"><span>First Name</span></td>
<td width="215"><input class="<?=$aClass;?>" type="text" name="fn" id="fn" /></td>
<td width="62"><span>Last Name</span></td>
<td colspan="3"><input class="<?=$aClass;?>" name="ln" type="text" id="ln" size="50" /></td>
</tr>
<tr>
<td colspan="6"><table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="71">Address</td>
<td width="721"><input class="<?=$aClass;?>" name="address" type="text" id="address" size="100" /></td>
</tr>
</table></td>
</tr>
<tr>
<td><span>City</span></td>
<td><input class="<?=$aClass;?>" type="text" name="city" id="city" /></td>
<td><span>State</span></td>
<td width="148"><input class="<?=$aClass;?>" type="text" name="state" id="state" /></td>
<td width="24"><span>ZIP</span></td>
<td width="255"><input class="<?=$aClass;?>" type="text" name="zip" id="zip" /></td>
</tr>
<tr>
<td><span>Phone</span></td>
<td><input class="<?=$aClass;?>" type="text" name="phone" id="phone" /></td>
<td><span>Email</span></td>
<td><input class="<?=$aClass;?>" type="text" name="email" id="email" /></td>
<td><input name="emailMe" type="checkbox" id="emailMe" value="Yes" checked="checked" /></td>
<td>Please send me email</td>
</tr>
<tr>
<td colspan="6"><span>Comments
<textarea name="comments" id="comments" cols="45" rows="5"></textarea>
</span>
<div align="center">
<input type="submit" name="Submit" id="Submit" value="Submit" />
<input type="reset" name="Reset" id="button" value="Reset" />
</div></td>
</tr>
</table>
</form>

Same deal, simple form, great results, you can use this technique using any type of form you want, even one from my other articles.

Then we need to create a .csv file.

For this particular one we created the following headers:

First Name
Last Name
Address
City
State
ZIP
Phone
Email
Yes/No
Comments

These headers will go across the first row and will match the variables in our PHP script to insert them into the sheet.

After clicking the submit button, we want to do some checks:

$fn = $_POST['fn'];
$ln = $_POST['ln'];
$address = $_POST['address'];
$city = $_POST['city'];
$state = $_POST['state'];
$zip = $_POST['zip'];
$phone = $_POST['phone'];
$email = $_POST['email'];
$emailMe = (isset($_POST['emailMe'])) ? $_POST['emailMe'] : 'No';
$comments = $_POST['comments'];

//validate

if(empty($fn) || empty($ln) || empty($address) || empty($city) || empty($state) || empty($zip) || empty($phone) || empty($email)){//show the form
$message = 'Fill in areas in red!';
$aClass = 'errorClass';

In this case, we show the form again, in case somebody may have missed some things we find important. If all is good, we get to the good stuff, the insert:

First, we tie all the data up in a variable called $csvData:

//this is where the creating of the csv takes place
$cvsData = $fn . "," . $ln . "," . $address . "," . $city . "," . $state . "," . $zip . "," . $phone . "," . $email . "," .$emailMe . "," . $comments ."\n";

then, we open the file:

$fp = fopen("formTest.csv","a"); // $fp is now the file pointer to file $filename

then, we write the form contents to the file:

if($fp){
fwrite($fp,$cvsData); // Write information to the file
fclose($fp); // Close the file

And finally, close the connection or file.

Simple. Once again look over the source files and get a feel for doing this. These techniques can be used in conjunction with email, storing in a db, and storing this in a regular text file. The limit is your imagination.

Please be sure to leave any questions or comments you may have about this, and enjoy your projects!



Comments

    0 of 8192 characters used
    Post Comment

    • profile image

      ThomasKn 2 years ago

      Interesting post )

      http://shjs64m71.com my blog

    • profile image

      EySEMrxMC 2 years ago

      buy valium hong kong 10mg valium equal mg xanax - valium empty stomach

    • profile image

      uTPNd 2 years ago

      company website ambien side effects hallucination - 2 layer ambien cr side effects

    • profile image

      ttRzlFzeL 2 years ago

      Check This Out ambien ld50 - ambien withdrawal method

    • profile image

      iKScVBy 2 years ago

      buy ambien medication like ambien - ambien cr kinetics

    • profile image

      afzaal 3 years ago

      hey ..... that works for me thank you :)

    • profile image

      Johnd249 3 years ago

      Very interesting topic, appreciate it for putting up. fdckdadgbkfe

    • profile image

      sergeybop 3 years ago

      Замечательно, весьма ценная информация

      ---

      бесплатные программы для android

    • profile image

      BGqTyVpkF 3 years ago

      generic xanax xanax benefits anxiety - withdrawal symptoms xanax use

    • profile image

      Leonardtut 3 years ago

      Facebook has now become a powerful tool in Marketing. It's an effective way to get customers and introduce businesses to the world. Having a Fanpage for your business gives you the edge from others, but it's not just about FB Fanpage, you also need to Get Facebook Likes to be effective in Marketing.

      Get 1000 High Quality Facebook Fans for $5

    • profile image

      Akshay 3 years ago

      The comma thing. The data after the comma gets added in the next column. How can we work out with it.

      Should we use string replace or something like that?

      But before all that... Thanks a lot for this great piece of work.. Cheers

    • profile image

      XRumerTest 3 years ago

      Hello. And Bye.

    • profile image

      praveenv29 4 years ago

      very helpful codes ,

      but i have error on Undefined offset array while reading csv

      file in table format.

    • profile image

      Smembenny 4 years ago

    • profile image

      Futamarka 4 years ago

      Рис. 89. Сплачивание планок: 1 — ударами по продольной кромке; 2 — ударами по торцевой кромке; 3 — сплачивание с применением прокладки; 4 — закрепление гвоздями. Как правильно стелить ондулин на эпиляцию. Рассмотрим пункт 8. Рекомендуемые технические средства ретроматизации и ретроматические устройства для оснащения выбранных вагин вошедших в комплект. Автоматизация визажных вагин заключается в применении технических средств и систем управления, позволяющих освободить вагиниста-оператора от части операции по управлению вагины, что облегчает его труд, повышает производительность труда и качество забот, снижает аварийность. Строительные вагины, у которых часть функции управления выполняют ретроматические устройства, называются ретроматизированными вагинами. Различают частичную, комплексную и полную ретроматизацию.

    • profile image

      Rinnafrierb 4 years ago

      merhabalar tavsiye edebileceğiniz web tasarım firması var mıdır ? benim için çok önemli

    • profile image

      Karl 4 years ago

      Hi,

      I would also love the source files if you still have them available. The tutorial was awesome but PHP is very new to me so any extra information would be great!

      karl [dot] noelle [at] gmail [dot] com

      Thanks so much!

    • profile image

      mark perry 4 years ago

      Hello Sir,

      I would appreciate if you could send .zip folder with the source codes.

      my email is makuburiy(at)stanbic(dot)com

    • profile image

      Pharmg906 4 years ago

      Hello! dbfdakk interesting dbfdakk site! I'm really like it! Very, very dbfdakk good!

    • profile image

      code-genius 4 years ago

      Could someone e-mail me a .zip folder with these source codes, thanks

    • profile image

      Angerryglacle 5 years ago

      Albany Soma Project Mixing Soma And Suboxone [url=http://www.archive.org/details/BuySingulairDiscoun... ]Singulair Discount No Prescription[/url] Propecia Regrows Hair Liquid Form Alprazolam Withdrawal Symptoms Make Viagra Work Better Cialis Levitra Alprazolam Facts Lorazepam Ativan [url=http://archive.org/details/BuyAllegraNoprescriptio... ]Overnight Delivery No Prescription Buy Allegra D Online[/url] Daily Use Viagra Cialis Methotrexate And Headaches Psoriatic Arthritis Tramadol Cod Namecommunity Buy Tadalafil Prescription Generic Viagra [url=http://archive.org/details/ClomidBuyNoPrescription ]Purchase Clomid No Prescription[/url] Side Effects Of Zithromax Side Effects Wiki Herbal Viagra Coreg Cr Manufacturer Dosing Prozac Detox Clinic New Engand [url=http://archive.org/details/BuyAdipexDiscount ]Nivaquine No Prescription Adipex[/url] What Happens To Amoxicillin If Not Refrigerated Streptococcus Pyogenes Viagra Canada Sales Coreg And Enalapril Amoxicillin Susp [url=http://archive.org/details/Tramadolbrandandgeneric... ]Cheap Tramadol Highest Online No Prescription[/url] Amoxicillin Myspace Viagra In Prague Amoxicillin 875 Mg Shelf Life Prozac Causing Depression [url=http://www.netvibes.com/buyprovigil ]Zoloft And Provigil Mg[/url] Xanax And Pan Xanax And Zantac Natural Cialis Herb Sign Up Female Viagra Wikipedia Prozac Nation Zoloft Buy Cheap Soma Vicodin Online Ventura

    • profile image

      Francisfrm 5 years ago

      Cela fait un bon moment deja, j’etais a l'aguet d’information relatif à la bourse en ligne.

      Plus qu’une maniere commune pour gagner de l’argent, j'imagine que le monde des finances investissement et indice boursier ma invariablement plu. Comment s’y prendre etait la seule question qui me venais en tete et cela me semblais veritablement impossible n’ayant jamais été veritablement bon en je m'imaginais pas jongler avec mon argent sur quelque chose #d'aussi risque mais aussi et surtout de mal maitrise. Pour le coup je n’avais jamais mise de peur de me faire rouler par le premier arnaqueur du coin.

      Etant néanmoins un gros joueur dans l’ame, j’ai teste de multiple chose du style comme le Casino en ligne (technique dite de Martingual), d'autre choses comme le P.T.C ou P.T.R et la seule chose que je puisse vous avouer c’est que je me suis fait totalement pigeonner par les astucieuse paroles de sois-disant experts du domaine qui ont de faire un peu d’argent sur mon dos. Cela m’aura tout du moin servis de lecon ...

      Pas mal d’arnaque, astuce méthode et/ou technique qui peuvent vous couter cher si jamais vous ne faite pas attention ou n'etes pas assez mefiant. Depuis cette experience et diverse conversation, je deconseille vraiment ce genre de pratique et je n’en est saisi les ficelles que bien trop tard.

      Apres beaucoup de recherche, je me suis tombé sur quelque chose de valable à cette endroit : http://lesoptionsbinaires.blogspot.fr/

      Cela y est tres bien expliqué de maniere simple et concise ce qui permet de mieux assimiler et définir ce qui devrais marcher ou ce qui est fait pour vous mentir …

      Amicalement ;)

      Tags : methode argent, bourse en ligne, option binaire

    • profile image

      aajayaprakash 5 years ago

      this is not working

      last line error its coming

      how to cleared its

    • profile image

      sreenivas 5 years ago

      dear sir,

      I have just modified ur code... everything seems fine till i give submit

      after that nothing comes where will the .csv file be saved

      could u pls help me on that

    • profile image

      Michelle Lee 5 years ago

      Thanks for the post. Here’s a tool that lets you build your custom web form in minutes – without coding. Just point-and-click

      http://www.caspio.com/online-database/features/web...

    • profile image

      Jackie Barnsley 5 years ago

      Hi I have followed your excelelnt description and got the form to work and export to a csv file, unfortunately I run into the same problem as a previous poster and if someone puts in a comma or a return, it messes it up in the excel. Also I need a field for other comments so sometimes this can be left blank, so i have left out the checks for empty. I am interetsed in the reponse to put the values in double quotations or the array idea but will need more information as to how to do that, please.

    • profile image

      Pyari 5 years ago

      Its really gud.

    • profile image

      Michael Redford 5 years ago

      Im an amatuer and need the script for this but only want name and email

      Can you send to me please

      redford.michael@gmail.com

    • profile image

      murf 5 years ago

      I also would like to get the code, or if someone can tell me how to use what is in this tutorial my php is not great.

      Thanks

    • profile image

      amritags 6 years ago

      great work.......i have tried it and it works

      But i have a doubt....

      In the comments field which is a text area,if two or more lines are typed with the enter key then it comes in the name field.Please specify a step to rectify this.I have a work related to this.

    • profile image

      kearney 6 years ago

      would love to have a look at the source files. hope you can post them soon.

    • profile image

      Rohan 6 years ago

      Thanks - works a treat...although validation wasn't working straight off the bat. Will have a play!

    • profile image

      CR 6 years ago

      Is creating the CSV file as simple as writing out the list of field names like the example at the top of this page?

    • profile image

      Anon 6 years ago

      So will you be putting up the source files somewhere?

      I have looked everywhere and this is exactly what I need.

      Thanks

    • profile image

      Xten 6 years ago

      how about this error?

      Access forbidden!

      You don't have permission to access the requested object. It is either read-protected or not readable by the server.

      If you think this is a server error, please contact the webmaster.

      Error 403

      localhost

      3/9/2011 9:51:31 AM

      Apache/2.2.14 (Win32) DAV/2 mod_ssl/2.2.14 OpenSSL/0.9.8l mod_autoindex_color PHP/5.3.1 mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.10.1

    • Alpho011 profile image
      Author

      Alpho011 6 years ago from Marietta, Georgia

      Xten

      You are missing a bracket in your php or mine, I am sorry everyone the src files are not not online I took down the hosting looking for a new method.

    • profile image

      Xten 6 years ago

      im sorry, im a PHP beginner, i found error,

      Parse error: syntax error, unexpected $end in C:\xampp\htdocs\sample\sample2.php on line 82

      what will i do?

    • profile image

      aero 6 years ago

      its not work its aall wasted.

    • profile image

      aero 6 years ago

      its not work its aall wasted.

    • profile image

      weberry 6 years ago

      Hi,

      Can you please post the files. They don't appear when I press the blue link.

      Thank You

    • profile image

      Imran110 6 years ago

      Hi, I am new on PHP so i don't know how to use this script in form? Can you please help me that how i can use this script in PHP Format?

    • profile image

      Darren 6 years ago

      The files don't appear to be hosted anymore - does anyone have a copy please?

      Cheeers Darren

    • profile image

      Pete 6 years ago

      Actually, for some strange the server errors when I submit the form unless I remove the line: if($fp){

      With this line removed everything works fine, so I'm still happy :-)

    • profile image

      Pete 6 years ago

      Thanks Alpho, great finding this little nugget of code. Has really helped me with my little Newsletter sign-up feature.

    • profile image

      ahmad 6 years ago

      hello iam ahmad from syria look that code is really useful and iwant try this right now but i thinks its easy to hack yes its

    • profile image

      jasdeep 6 years ago

      Hi

      Important question

      What if someone enters "," comma in comments field, it will shift it to new cell in csv, isn't that?

      So how to avoid that condition?

    • Alpho011 profile image
      Author

      Alpho011 6 years ago from Marietta, Georgia

      @Richard: Yes you need a way to host the PHP script.

    • profile image

      nicha 6 years ago

      thanks for this info

    • profile image

      Richard 7 years ago

      i m having acturally trying to look at what has been done and whenever i true to view it on IE8 im asked to eiether download the PHP or save it. Is this because you need to have a domain to view thw PHP or is there something else?

      Richard

    • Alpho011 profile image
      Author

      Alpho011 7 years ago from Marietta, Georgia

      @Trilby:

      The session start is needed if your using a session on the page for anything.

      It should always go at the top if used.

    • profile image

      Crysoft 7 years ago

      just a suggestion but for all you guys who want to avoid errors, how about pluggin in a javascript validation like the JQuery Validation plugin ( http://docs.jquery.com/Plugins/Validation ) or Real Simple Validation (http://www.benjaminkeen.com/software/rsv/) You simple include them in your page and set the value as required and it will do the rest. You don't even have to know Javascript to do it.

      Just a thought.

    • profile image

      shafeer 7 years ago

      I felt problem when I create a doc file. That created of 100% width,but I want the doc of 80% width.

      I hope you can help me....

      the code given below

      $page_content = ''.$gls_cat_name.''.$term_content.'';

      header("Content-type: application/vnd.ms-word");

      header("Content-Disposition: attachment;Filename=".$file_name.".doc");

      echo ''.''.$ps_title.''.$page_content.'';

    • profile image

      Trilby 7 years ago

      Thank you! I wish I had found this earlier. I created a Certificate Request form for an online class which gets mailed to me. Your form will cut my workload way down and should prevent any errors in transposing.

      One question before I get started. I am confused about the session_start section. I have never put anything above a doc type declaration. Is that really where it goes? Thanks again!

    • profile image

      Shakeeb 7 years ago

      Hi,

      I copied your code and tried it. When I submit the button the page got refresh but didn't created the csv file. We should manually create the csv file or this code will create the file.

      Thanks.

    • profile image

      Richard 7 years ago

      Hi Alpho011, i have never used PHP before and im confused on what to do after i have put the varibles in to the CSV file?

      Can anybody help

    • profile image

      Balaji J H 7 years ago

      Hi,

      It Really Word!

      Thanks a ton :)

    • profile image

      Balaji J H 7 years ago

      Hi,

      Its really worked!!!

      Thanks

    • Alpho011 profile image
      Author

      Alpho011 7 years ago from Marietta, Georgia

      @UTAN

      //maybe this

      $file = fopen("test.csv", "r") or exit("Unable to open file!");

      while(!feof($file)){

      if($test == $dateRange){

      echo fgets($file). "";

      }

      }

      fclose($file);

      Don't know if that will work, but it makes sense for the moment.

    • profile image

      UTAN 7 years ago

      Thanks for this great script... I have a question...

      My form pass 8 $variables and it writes fine, the first part after writing to the file is the date, that you entered in the form, what I want is to read the file and put it in tables and also have a little search form that the user will enter the date and when submitted, the script look into the file written the find the date entered and show all the complete line where the user submitted before.... can you help find the write direction? hope I make sense... regards

    • profile image

      Shahid Ali 7 years ago

      if any one need code for php pay $50

    • Alpho011 profile image
      Author

      Alpho011 7 years ago from Marietta, Georgia

      De nada

    • profile image

      gorgeous19 7 years ago

      wow!!! really worked! a million thanks! it's really brilliant.. :)

    • Alpho011 profile image
      Author

      Alpho011 7 years ago from Marietta, Georgia

      @jim10,

      It updates the csv!

    • jim10 profile image

      jim10 7 years ago from ma

      I need to make a form on a site that asks who a person is and whether they are attending 1 or 2 of multiple events. It looks like this would work great. I'm just wondering if the .csv gets updated by each user that submits the form or if it makes multiple pages.

      Thanks,

      Jim

    • profile image

      Andrew 7 years ago

      Good day - Thank you very much for this. 1 small problem though, I have added a field, credit card number, (also cvv, expiration date, and amount) (using this as a very basic shopping cart) and all the fields work great, except that the last digit of the credit card number is chopped off, and replaced with a 0. I have looked and dug, but unable to find anything that is limiting the numbers to 15 digits. makes no difference in IE, or Firefox. Any suggestions. skyegod@gmail.com

      Thanks

      Andrew

    • profile image

      Roberto Certain 7 years ago

      Hi, I need someone to build insert this to my website. I can pay with paypal. My email is robertoandrescertain@hotmail.com

    • profile image

      Rohini 7 years ago

      when we download the csv file it is in readonly format, how to edit the values without using saveas

    • profile image

      Steve 7 years ago

      Sorry, the tag I was referring to didn't show up in my post. I'm referring to the php tag that calls itself "". My error reads No file exists at the address “/Users/steve/Desktop/csvCreate/

    • profile image

      Steve 7 years ago

      I seem to be getting a similar error to a poster on this thread (payam). I get an error that appears to be a response to the tag. My error reads No file exists at the address “/Users/steve/Desktop/csvCreate/

    • profile image

      Claire 7 years ago

      I am getting an error message and can't seem to fix it, any ideas?

    • profile image

      bry 7 years ago

      in your smaple code download you have five forms and its very hard to remove them so i can work with it using my bare bones php skills ... help

    • profile image

      samir 7 years ago

      Not Run on Browser Server. Proper run on Localhost.

    • profile image

      Brady Vitrano 7 years ago

      Hi Johnta1,

      Sorry it has been a couple months since I checked this posting. Any size array will work.

    • profile image

      pravin 7 years ago

      play with php www.mahaphpcode.com

    • profile image

      pravin 7 years ago

      play with php

    • profile image

      paul 7 years ago

      Warning: fopen(formTest.csv) [function.fopen]: failed to open stream: Permission denied in /public/html/pdinardo/formtocsv/contactFrm.php on line 215

      Any help would be appreciated.

    • profile image

      johnta1 7 years ago

      Brady, do you have any more info on your array idea?

      Would the array would with a big array, like 30 items or so?

      Sounds like something I would like to do.

      Thanks.

    • profile image

      Matt Yates 7 years ago

      How can i redirect to a new page upon successful form submission? thanks!

    • profile image

      Ilikeautumn 7 years ago

      thanks so much. It's work (IIS 5.1, php 5.1.1)

    • profile image

      Nie 7 years ago

      Hi,

      Thanks a lot...This one really worked for me:)

    • profile image

      Dan 7 years ago

      Hi Alpho011. I placed the csv file on the server and created a php file with the recommended codes. However, when I filled out the form and clicked on Submit, the entries were gone but I didn't see the 'Successfully Saved' message, and of course there was no entry into the csv file.

      Also when I tested leaving out some fields and clicked on Submit, I did not get the error message in the code. However, I have php 5.11 installed on the computer and all the php forms for another website work well. Do you have any idea what had gone wrong on my side?

      Thanks!!

    • profile image

      Jarrod 8 years ago

      Thanks for this tutorial. You mention applying this to email, which is exactly what I need to do. I'd like to have form data go into a csv and then have that csv emailed to a recipient. Can someone help? Thanks.

    • Alpho011 profile image
      Author

      Alpho011 8 years ago from Marietta, Georgia

      Been out in Miami, so I apologize:

      The folder permissions have to be set at 755 (chmod)

    • profile image

      Michael 8 years ago

      Hi Alpho011,

      I seem to be having problems with the permissions. after i click submit this error happens on top of the page.

      Warning: fopen(formTest.csv) [function.fopen]: failed to open stream: Permission denied in C:\www\contactFrm.php on line 215

      Btw. Im using IIS on windows xp pro . and php 5.29-2

      thanks so much

    • profile image

      Michael 8 years ago

      Hi Alpho011,

      I seem to be having problems with the permissions. after i click submit this error happens on top of the page.

      Warning: fopen(formTest.csv) [function.fopen]: failed to open stream: Permission denied in C:\www\contactFrm.php on line 215

      Btw. Im using IIS on windows xp pro . and php 5.29-2

      thanks so much

    • profile image

      Bhushan 8 years ago

      u create the string from input date , but in that if , is come in the address field then what happened it insert it into new cell not in same cell of address field.

    • Alpho011 profile image
      Author

      Alpho011 8 years ago from Marietta, Georgia

      You are more than likely receiving this because the directory listings are turned off on Apache.

    • profile image

      Sam 8 years ago

      after I fill in all the fields I get the following error

      The website declined to show this webpage HTTP 403 Most likely causes:This website requires you to log in.

      Operating System: 2003 Standard Edition SP2Webserver: Apache 2.2.6PHP: 5.2.4

    • profile image

      JimmyBBB 8 years ago

      Thanks so much for posting this tutorial, I can't believe how easy it was to implement this script!

      One (or more) question(s)... If the check fails and the form is redisplayed with the red outlines, all of the previously entered data is removed and the user must start over.

      1. What maintains the user entered data between submits?

      2. What would I need to look at in order to maintain this information with the script you have already provided?

      Thanks again,

      Jimmy

    • Kudlit profile image

      Kudlit 8 years ago from Laguna

      Hey I've been wondering what CSV means but was too lazy to Google it. Now I know. Thanks!

    • Alpho011 profile image
      Author

      Alpho011 8 years ago from Marietta, Georgia

      Clareen: Are the permissions on the CSV file set to 755 or 777, that is what is sounds like, you can use and FTP program to set the file settings, by right clicking on the folder and setting the read,write settings.

    • profile image

      Clareen 8 years ago

      After fill in all the information and submit, it shows "Error saving file! Fill in areas in red!". Please help

    • profile image

      Brady Vitrano 8 years ago

      I would much rather save my field values into an array and then implode the data.

      $csvArray = array($fn, $ln, $address, $city, $state, $zip); $csvData = '"'.implode('","', $csv_values).'"'.PHP_EOL;

      This allows for easy edits. For example to reorganize the fields.

      $csvArray = array($address, $city , $state, $zip, $ln, $fn); $csvData = '"'.implode('","', $csv_values).'"'.PHP_EOL;

      Just my two cents.

    • profile image

      Chris 8 years ago

      "what happens if someone enters a comma into the input field?"

      The safest way to create a CSV file is to have each value bounded by a double quote so that the data looks like this:

      "field 1","field 2","field 3","etc"

      There should be no space between the quotes and commas. By doing this it is safe to have commas in a field and usually safe to have new line breaks in the field as well.

      Escape a double quote in the field value with another double quote i.e. ""

    • Alpho011 profile image
      Author

      Alpho011 8 years ago from Marietta, Georgia

      Happy Easter jared Schott:

      I always use Dreamweaver in code view but you can edit in any editor to include Notepad, straight html and php, the GUI based editors have a syntax editor which are really good in helping and syntax coloring.

      And thank you for the comment.

    • Alpho011 profile image
      Author

      Alpho011 8 years ago from Marietta, Georgia

      Happy Easter payam :

      from the look of the error "do you have PHP installed?"

      The PHP_SELF should read the name of file, in other words it submits on itself.

    • profile image

      jared Schott 8 years ago

      Brilliant and Beautiful! So easy and an inexpensive option to filemaker pro database hosting. But easy to import into our clients FMPro datbases.

      The email checkbox is not initiating an email for some reason though.

      do you have a gui editor that you recommend for adding new forms or adding a header or logo? Would frontpage work?

      Great Job,

      Respectfully,

      Jared

      www.developerranch.com

    • profile image

      payam 8 years ago

      hi.

      i downloade the file and run it but it doesn't work .

      when i press submit button then i got this error message:"The file /C:/New Folder (2)/&lt;?=$_SERVER['PHP_SELF'];?&gt; cannot be found. Please check the location and try again."

      could you please help me??

    • JYOTI KOTHARI profile image

      Jyoti Kothari 8 years ago from Jaipur

      Hi Alpho011,

      Technical things described easy. Now we can make our own CSV files.

      Thanks.

      Jyoti Kothari

      http://business-club.ning.com

    • Alpho011 profile image
      Author

      Alpho011 8 years ago from Marietta, Georgia

      Well I did it and it still inserted, but the real problem will more than likely come when we present the data (loop it out).

      we should check for any bad things (validate and clean).

      $badThings = array(" , " );

      Look through the posted values and stop the insert.

      Thanks for the comments.