Skip to content

Instantly share code, notes, and snippets.

@alganet
Created May 16, 2012 20:59
Show Gist options
  • Save alganet/2713910 to your computer and use it in GitHub Desktop.
Save alganet/2713910 to your computer and use it in GitHub Desktop.
PHP Form
<?php
$data = $_POST['contact']; //get all fields (contact[full_name], etc)
ksort($data); //sort the fields by name, so changing the order on HTML don't change the order in the spreadsheet
$fileHandle = fopen('contact.csv', 'a'); //opens the contact.csv file, creates it if doesn't exist, place the cursor at the end of the file
fputcsv($fileHandle, array($contact_data)); //write contact data to the end of the file
<form method="post" action="contact.php">
<label>Full Name: <input type="text" name="contact[full_name]"></label>
<label>Phone: <input type="text" name="contact[phone]"></label>
<label>Message: <textarea name="contact[message]"></textarea></label>
<button type="submit">Enviar</button>
</form>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment