It's been a LONG time since i've messed with php, but i remember some of the basics... For some reason i can't seem to find any information on how to create a php form that saves the input to an excel file... I've tried a few file modification methods, but it corrupts the file and can't be read anymore... I know there's GOT to be a simple way to acheive this!
Any help is greatly appreciated!
-K0D3R
Simple Script?
Moderator: General Moderators
- gregwhitworth
- Forum Commoner
- Posts: 53
- Joined: Tue Oct 09, 2007 1:00 am
- Location: Wasilla, Alaska
Code: Select all
<?php
header ("Location: http://www.karenwhitworth.net/thankyou.htm");
//Contact form field variable settings.
$name = $_POST['name'];
$email = $_POST['email'];
$phone = $_POST['phone'];
$msg = $_POST['message'];
$newsletter = $_POST['newsletter'];
$cr = "\n";
$data = $email .$cr;
$file = "newsletter.csv";
//newsletter setting
if (!$file_handle = fopen($file, "a"))
{echo "Cannot open file";
}
if (!fwrite($file_handle, $data)) {
echo "Cannot write to file";}
echo "You have successfully written data to $file";
fclose($file_handle);
//Configurations for email
$to = "";
$subject = "Form Response at Karen Whitworth.net";
$body = "From: $name <$email>\n\n";
$body .= "$msg";
mail($to, $subject, $body, "From: $email");
?>Code: Select all
//newsletter setting
if (!$file_handle = fopen($file, "a"))
{echo "Cannot open file";
}
if (!fwrite($file_handle, $data)) {
echo "Cannot write to file";}
echo "You have successfully written data to $file";
fclose($file_handle);That's it, I hope this helps.
--
Greg