adapting a form for a client but my PHP is lousy and only up to tweaking here and there was hoping someone could please help me out?
Basically if the form is submitted and the MegaMix checkboxes are left blank the page comes up with an error. I need to use If and isset to only process Megamix if one of the boxes has been ticked.
I'm not sure how best to approach this?
would appreciate any advice anyone can give
$EmailFrom = "info@bubblesoccerscotland.co.uk";
$EmailTo = "info@design-hero.com";
$Subject = "Bubble Scotland MegaMix Enquiry for Edinburgh (City Centre)";
$Option = Trim(stripslashes($_POST['Option']));
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['Email']));
$Tel = Trim(stripslashes($_POST['Tel']));
$Players = Trim(stripslashes($_POST['Players']));
$Location = 'Edinburgh (City Centre)';
$Date = Trim(stripslashes($_POST['Date']));
$Time = Trim(stripslashes($_POST['Time']));
$Message = Trim(stripslashes($_POST['Message']));
$Megamix = join(", ", $_REQUEST["Megamix"]);
// prepare email body text
$Body = "";
$Body .= "Option: ";
$Body .= $Option;
$Body .= "\n";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "Tel: ";
$Body .= $Tel;
$Body .= "\n";
$Body .= "Email: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Players: ";
$Body .= $Players;
$Body .= "\n";
$Body .= "Location: ";
$Body .= $Location;
$Body .= "\n";
$Body .= "Date: ";
$Body .= $Date;
$Body .= "\n";
$Body .= "Time: ";
$Body .= $Time;
$Body .= "\n";
$Body .= "Message: ";
$Body .= $Message;
$Body .= "\n";
$Body .= "Megamix: ";
$Body .= $Megamix;
$Body .= "\n";
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"1;URL=enquiry-success.php\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"1;URL=enquiry-fail.php\">";
}
Aucun commentaire:
Enregistrer un commentaire