Hey, I'm just learning PHP. I've written some code that takes information from an html form and appends it to a csv file on the server. It then sends a simple email back to me, just to notify me that new information has been submitted. Here it is:
php
<?php
echo $_GET["name"], "<br />", $_GET["address"], "<br />", $_GET["city"], "<br />", $_GET["state"], "<br />", $_GET["zip"], "<br />", $_GET["email"];
$myFile = "serverinfo.csv";
$fh = fopen($myFile, 'a') or die("can't open file");
$space = ",";
fwrite($fh, $_GET["name"].$space);
fwrite($fh, $_GET["address"].$space);
fwrite($fh, $_GET["city"].$space);
fwrite($fh, $_GET["state"].$space);
fwrite($fh, $_GET["zip"].$space);
fwrite($fh, $_GET["email"].$space);
fclose($fh);
$Name = "Automated E-Mail"; //senders name
$email = "email@address.com"; //senders e-mail adress
$recipient = "example@yahoo.com";
$mail_body = "Someone has submitted new information to your form!";
$subject = "It Works!";
$header = "From: ". $Name . " <" . $email . ">\r\n"; //optional headerfields
ini_set('sendmail_from', 'me@domain.com');
mail($recipient, $subject, $mail_body, $header);
?>
My first problem is that I don't know how to start writing to a new row in the csv. It goes to a new column for each variable, but after (or before) all of them are written, I'd like to have a new row.
Just another minor problem is that the e-mails literally take about 2 hours to get to the yahoo account they're sent to. Can anyone please help with this as well?
This post has been edited by steevo301: 30 Oct, 2008 - 04:09 AM