PHP ver gevorderde |
|
Ik heb een php script voor het verzenden van wat inputvelden. Maar ik wil dat wanneer je een bepaalde optie gekozen hebt, het script een aantal andere velden controleert of deze zijn ingevuld. Maar hij geeft aan dat er een fout zit in regel 65, $Body .= "\n"; een beetje raar dus.
Hieronder is het script:
<?php
// Website Contact Form Generator
// http://www.tele-pro.co.uk/scripts/contact_form/
// This script is free to use as long as you
// retain the credit link
// get posted data into local variables
$EmailFrom = Trim(stripslashes($_POST['Name']));
$EmailTo = "mail@why-online.com";
$Subject = "Demo order";
$Name = Trim(stripslashes($_POST['Name']));
$Email = Trim(stripslashes($_POST['E-mail']));
$Amount = Trim(stripslashes($_POST['Number']));
$Receive = Trim(stripslashes($_POST['Receive']));
$Address = Trim(stripslashes($_POST['Address']));
$Postal = Trim(stripslashes($_POST['Postal']));
$Place = Trim(stripslashes($_POST['Place']));
$Pickup = Trim(stripslashes($_POST['Pickup']));
$Comment = Trim(stripslashes($_POST['Comment']));
// validation
$validationOK=true;
if (Trim($Name)=="") $validationOK=false;
if (Trim($Email)=="") $validationOK=false;
if (Trim($Amount)=="Not chosen") $validationOK=false;
if (Trim($Receive)=="Not chosen") $validationOK=false;
if (!$validationOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=phperror.html\">";
exit;
}
// Adress validation by Paul
$validateOK=true;
if (Trim($Receive)=="Send to") if (Trim($Address)=="") $validateOK=false;
if (Trim($Receive)=="Send to") if (Trim($Place)=="") $validatOK=false;
if (Trim($Receive)=="Pick up") if (Trim($Pickup)=="Not chosen") $validateOK=false;
if (!$validateOK) {
print "<meta http-equiv=\"refresh\" content=\"0;URL=phperror.html\">";
exit;
}
// prepare email body text
$Body = "Personal information";
$Body .= "Name: ";
$Body .= $Name;
$Body .= "\n";
$Body .= "E-mail: ";
$Body .= $Email;
$Body .= "\n";
$Body .= "Number: ";
$Body .= $Amount;
$Body .= "\n";
$Body .= "Receive ";
$Body .= $Receive;
$Body .= "\n";
$Body .= "Pick up at: ";
$Body .= $Pickup;
$Body .= "\n";
$Body .= "Send to: ";
$Body .= $Address;
$Body .= "\n";
$Body .= $Place
$Body .= "\n";
$Body .= "Comment: ";
$Body .= $Comment
// send email
$success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>");
// redirect to success page
if ($success){
print "<meta http-equiv=\"refresh\" content=\"0;URL=phpok.html\">";
}
else{
print "<meta http-equiv=\"refresh\" content=\"0;URL=phperror.html\">";
}
?>
<?php // Website Contact Form Generator // http://www.tele-pro.co.uk/scripts/contact_form/ // This script is free to use as long as you // retain the credit link // get posted data into local variables $EmailTo = "mail@why-online.com"; $Subject = "Demo order"; // validation $validationOK=true; if (Trim($Name)=="") $validationOK=false; if (Trim($Email)=="") $validationOK=false; if (Trim($Amount)=="Not chosen") $validationOK=false; if (Trim($Receive)=="Not chosen") $validationOK=false; if (!$validationOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=phperror.html\">"; } // Adress validation by Paul $validateOK=true; if (Trim($Receive)=="Send to") if (Trim($Address)=="") $validateOK=false; if (Trim($Receive)=="Send to") if (Trim($Place)=="") $validatOK=false; if (Trim($Receive)=="Pick up") if (Trim($Pickup)=="Not chosen") $validateOK=false; if (!$validateOK) { print "<meta http-equiv=\"refresh\" content=\"0;URL=phperror.html\">"; } // prepare email body text $Body = "Personal information"; $Body .= "Name: "; $Body .= $Name; $Body .= "\n"; $Body .= "E-mail: "; $Body .= $Email; $Body .= "\n"; $Body .= "Number: "; $Body .= $Amount; $Body .= "\n"; $Body .= "Receive "; $Body .= $Receive; $Body .= "\n"; $Body .= "Pick up at: "; $Body .= $Pickup; $Body .= "\n"; $Body .= "Send to: "; $Body .= $Address; $Body .= "\n"; $Body .= $Place $Body .= "\n"; $Body .= "Comment: "; $Body .= $Comment // send email $success = mail($EmailTo, $Subject, $Body, "From: <$EmailFrom>"); // redirect to success page if ($success){ print "<meta http-equiv=\"refresh\" content=\"0;URL=phpok.html\">"; } else{ print "<meta http-equiv=\"refresh\" content=\"0;URL=phperror.html\">"; } ?>
Kan iemand mij hier helpen?
|