I have a form that I am currently updating to add some fields. I also now want to save the form data to an excel file as well as email the data.
I have no idea how to add a new row to an existing excel file (or CSV)
The basic page that currently sends the form via email is below, I want to just add this same data to an excel sheet.
$sql="insert into requests (email,phone,name,time,address,date,studies,program,experience,friends,dietary,week)
values (".safe(array($Email,$Phone,$Full_name)).",NOW(),".safe(array($Address,$date,$studies_in_Israel,$program_of_study,$experience, $number_of_friends,$Dietary_restrictions,$weeks)).")";
mysql_query($sql);
//echo $sql;
//echo mysql_error();
$id=mysql_insert_id();
$city=$_POST['city'];
$allcities=implode(",",$city);
$list=mysql_query("select name from cities WHERE id IN (" .$allcities . ")");
while($t=mysql_fetch_assoc($list))
{
$add[]= $t['name'];
}
$cities="\nCities requested: ". implode(",",$add);
foreach($city as $key=>$value)
{
$added="";
mysql_query("insert into city_requests (id,city) VALUES ('".$id."','".$value."')");
$subject = "AnywhereInIsrael: Shabbos Request";
$header = "From: info@AnywhereInIsrael.com\nReply-To: $Full_name <$Email>\n";
$message = "
For this coming shabbos, ".date("M j",$date)."
$_POST[Full_name] and a friend have requested a place for Shabbos.";
if ($_POST[studies_in_Israel]) {
$message .= "\n$POST[Full_name] Studies at: $POST[program_of_study]";
}
$message .= "
Is looking for: $_POST[experience]
$_POST[Full_name] can be reached at:
Email: $_POST[Email]
Phone: $_POST[Phone]
Address: $_POST[Address]
Dietary Restrictions: $_POST[Dietary_restrictions]";
$message.= $cities;
$adminmsg="\nWants to be contacted for subsidized Shabbatons? $POST[contact_for_subsidized]\n";
$adminmsg.="Wants to be contacted for HAS credit card? $POST[contact_for_HAS]\n";
$sql="select hosts.name,hosts.email,hosts.id from hosts WHERE hosts.city IN ('" .$value . "')";
$result=mysql_query($sql);
$count=mysql_numrows($result);
for ($j = 0; $j < $count; $j++) {
$emails=mysql_fetch_array($result);
$to = "$emails[email], ";
$added="\n\nTo send an invite to this person, please open this website and follow the instructions:\n$PATH/invites.php?do=send&hid={$emails[id]}&rid=$id&verify=".crc32($emails['email']."verification".$id);
$mailsuccess = mail($to, $subject, stripslashes($message.$added), $header);
if (!$mailsuccess) {
mail("lisigef@gmail.com", "AII mail not sent", $message, "From: info@AnywhereInIsrael.com");
}
}
/if($i!=0) mail_($to, $subject, stripslashes($message.$added), $header);//log emails turned off /
}
mail("info@AnywhereInIsrael.com", $subject."adminemail", stripslashes($message.$adminmsg), $header);
?>