Hi,
I have a php based enquiry form on my website.
As well as sending the enquiry by email, I want to store the enquiry on the website in a csv file.
I pulled a bit of coding from another php script I have & added the code to my mail.php3 file (at the end of the post).
It fails on 2 lines:
open(LOGFILE, “>>$logfile”) or die “Can’t open $logfile: $!”;
and
print LOGFILE “$date2,$name,$hphone,$wphone,$mobile,$convenient,$email,$hours,$type,$date,$sex,$receptions,$bedrooms,$bathrooms,$ironing,$pets,$commentsn”;
I can’t see anything wrong with them!
=================
<?php
$name = $_REQUEST[‘name’];
$address = $
$hphone = $_REQUEST[‘housephone’];
$wphone = $
$mobile = $_REQUEST[‘mobile’];
$convenient = $
$email = $_REQUEST[’email’];
$hours = $
$type = $_REQUEST[‘type’];
$date = $
$sex = $_REQUEST[‘sex’];
$receptions = $
$bedrooms = $_REQUEST[‘bedrooms’];
$bathrooms = $
$ironing = $_REQUEST[‘ironing’];
$pets = $
$comments = $_REQUEST[‘comments’];
$logfile = “enquirylogs/enquiry.csv”;
$adminaddress = “
$sitename = “Maid2Clean”;
$mail = mail(“$adminaddress”,”Client Request from maid2clean.org.uk”,
“*******************************************************************************
Name: $name
Home Phone: $hphone
Work Phone: $wphone
Mobile: $mobile
Time to Call: $convenient
Email: $email
HoursRequired: $hours
Clean Type: $type
Start Date: $date
MaleFemale cleaner: $sex
Receptions: $receptions
Bedrooms: $bedrooms
Bathrooms: $bathrooms
Ironing Required: $ironing
Any Pets: $pets
Address:
$address
Comments:
$comments”,”FROM:$adminaddress”);
$date2 = `date
chomp($date2);
open(LOGFILE, “>>$logfile”) or die “Can’t open $logfile: $!”;
flock(LOGFILE,2);
seek(LOGFILE,0,2);
print LOGFILE “$date2,$name,$hphone,$wphone,$mobile,$convenient,$email,$hours,$type,$date,$sex,$receptions,$bedrooms,$bathrooms,$ironing,$pets,$commentsn”;
flock(LOGFILE,8);
close LOGFILE;
if($mail)
{header( “Location:
else
{print “There was an error sending your enquiry, please try again.”; }
?>