| Discussion Home | About | Threads By Date | Search |
Title
.php form submit button goes to a .cvs file
Content
Can anyone tell me what code and exactly where to add to my current .php form that will send the information straight to a .cvs file. I already have the formTest.cvs file on the server with the appropriate fields in the excel sprreadsheet.
My php.ini file is on the server too. Will I need to alter that as well?
Thanks for any help!
Here is my current code:
Code
Code
<?php
require_once "Mail.php";
$from = "<myemailishere>";
$recipients['To'] = 'myemailishere';
$subject = "CONTACT FROM WEB SITE";
$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'];
$body = "
FIRST NAME:
$fn
LAST NAME:
$ln
ADDRESS:
$address
CITY:
$city
STATE:
$state
ZIP CODE:
$zip
PHONE NUMBER:
$phone
EMAIL:
$email
COMMENTS:
$comments";
$host = "localhost";
$username = "myemailishere";
$password = "mypasswordishere";
$headers = array ('From' => $from,
'To' => $to,
'Subject' => $subject);
$smtp = Mail::factory('smtp',
array ('host' => $host,
'auth' => true,
'username' => $username,
'password' => $password));
$mail = $smtp->send($recipients, $headers, $body);
if (PEAR::isError($mail)) {
echo("<p>" . $mail->getMessage() . "</p>");
} else {
echo("");
}
?>