Beste lezers,
Is er iemand die me kan vertellen wat er in dit script fout gaat? Als ik debug krijg ik geen foutmelding. Wanneer ik op de site de verplichte velden invul, blijf ik naar fout.php gaan, terwijl ik verwacht op bedankt.php te komen.
<?PHP
$FTGnaam = $naam;
$FTGadres = $adres;
$FTGpostcplaats = $postcplaats;
$FTGland = $land;
$FTGtelefoon = $telefoon;
$FTGemail = $email;
$FTGdatabank = $databank;
$FTGCystin_Newfy = $Cystin_Newfy;
$FTGCt_Bedl = $Ct_Bedl;
$FTGMDR1 = $MDR1;
$FTGCystin_Labra = $Cystin_Labra;
$FTGprofiel = $profiel;
$FTGEDTA_bloed = $EDTA_bloed;
$FTGswab = $swab;
$FTGswab_ja = $swab_ja;
$FTGswab_nee = $swab_nee;
$FTGras_populatie = $ras_populatie;
$FTGreg_nummer = $reg_nummer;
$FTGchipnummer = $chipnummer;
$FTGnaam_dier = $naam_dier;
$FTGgeb_datum = $geb_datum;
$FTGgeslacht_man = $geslacht_man;
$FTGgeslacht_vrouw = $geslacht_vrouw;
$FTGid_ja = $id_ja;
$FTGid_nee = $id_nee;
$FTGdierarts_naam = $dierarts_naam;
$FTGdierarts_praktijk = $dierarts_praktijk;
$FTGdierarts_adres = $dierarts_adres;
$FTGdierarts_plaats = $dierarts_plaats;
$FTGdierartsland = $dierartsland;
$FTGdierartstelefoon = $dierartstelefoon;
$FTGdierartsmail = $dierartsmail;
# Validate: String
function check_string($value, $low, $high, $mode, $optional)
{
if ( (strlen($value) == 0) && ($optional === true) ) {
return true;
} elseif ( (strlen($value) >= $low) && ($mode == 1) ) {
return true;
} elseif ( (strlen($value) <= $high) && ($mode == 2) ) {
return true;
} elseif ( (strlen($value) >= $low) && (strlen($value) <= $high) && ($mode == 3) ) {
return true;
} else {
return false;
}
}
#----------
# Validate: Email
function check_email($email, $optional)
{
if ( (strlen($email) == 0) && ($optional === true) ) {
return true;
} elseif ( ereg("[A-Za-z0-9_-]+\@[A-Za-z0-9_-]+\.[A-Za-z0-9_-]+", $email) ) {
return true;
} else {
return false;
}
}
# Fields Validations
$validationFailed = false;
if ( (! check_string($FTGnaam, 1, 0, 1, false))) {
$validationFailed = true;
}
if ( (! check_string($FTGadres, 1, 0, 1, false))) {
$validationFailed = true;
}
if ( (! check_string($FTGpostcplaats, 1, 0, 1, false))) {
$validationFailed = true;
}
if ( (! check_string($FTGtelefoon, 1, 0, 1, false))) {
$validationFailed = true;
}
if ( (! check_email($FTGemail, false))) {
$validationFailed = true;
}
# Redirect user to the error page
if ($validationFailed == true) {
header("Location: fout.php");
exit;
}
# Email to Form Owner
$emailTo = '"Genetic Counselling Services" <[email protected]>';
$emailSubject = "bestelling";
$emailBody = "naam: $FTGnaam\n"
. "adres: $FTGadres\n"
. "postcplaats: $FTGpostcplaats\n"
. "land: $FTGland\n"
. "telefoon: $FTGtelefoon\n"
. "email: $FTGemail\n"
. "databank: $FTGdatabank\n"
. "Cystin_Newfy: $FTGCystin_Newfy\n"
. "Ct_Bedl: $FTGCt_Bedl\n"
. "MDR1: $FTGMDR1\n"
. "Cystin_Labra: $FTGCystin_Labra\n"
. "profiel: $FTGprofiel\n"
. "EDTA_bloed: $FTGEDTA_bloed\n"
. "swab: $FTGswab\n"
. "swab_ja: $FTGswab_ja\n"
. "swab_nee: $FTGswab_nee\n"
. "ras_populatie: $FTGras_populatie\n"
. "reg_nummer: $FTGreg_nummer\n"
. "chipnummer: $FTGchipnummer\n"
. "naam_dier: $FTGnaam_dier\n"
. "geb_datum: $FTGgeb_datum\n"
. "geslacht_man: $FTGgeslacht_man\n"
. "geslacht_vrouw: $FTGgeslacht_vrouw\n"
. "id_ja: $FTGid_ja\n"
. "id_nee: $FTGid_nee\n"
. "dierarts_naam: $FTGdierarts_naam\n"
. "dierarts_praktijk: $FTGdierarts_praktijk\n"
. "dierarts_adres: $FTGdierarts_adres\n"
. "dierarts_plaats: $FTGdierarts_plaats\n"
. "dierartsland: $FTGdierartsland\n"
. "dierartstelefoon: $FTGdierartstelefoon\n"
. "dierartsmail: $FTGdierartsmail\n"
. "\n"
. "";
$emailHeader = "From: $FTGemail\n"
. "Reply-To: $FTGemail\n"
. "Content-type: text/plain; charset=\"ISO-8859-1\"\n"
. "Content-transfer-encoding: quoted-printable;\n";
mail($emailTo, $emailSubject, $emailBody, $emailHeader);
# Dump field values to text file
$dumpRecord = '"' . date('Y-m-d H:i:s') . '", ' . '"' . $FTGnaam . '", ' . '"' . $FTGadres . '", ' . '"' . $FTGpostcplaats . '", ' . '"' . $FTGland . '", ' . '"' . $FTGtelefoon . '", ' . '"' . $FTGemail . '", ' . '"' . $FTGdatabank . '", ' . '"' . $FTGCystin_Newfy . '", ' . '"' . $FTGCt_Bedl . '", ' . '"' . $FTGMDR1 . '", ' . '"' . $FTGCystin_Labra . '", ' . '"' . $FTGprofiel . '", ' . '"' . $FTGEDTA_bloed . '", ' . '"' . $FTGswab . '", ' . '"' . $FTGswab_ja . '", ' . '"' . $FTGswab_nee . '", ' . '"' . $FTGras_populatie . '", ' . '"' . $FTGreg_nummer . '", ' . '"' . $FTGchipnummer . '", ' . '"' . $FTGnaam_dier . '", ' . '"' . $FTGgeb_datum . '", ' . '"' . $FTGgeslacht_man . '", ' . '"' . $FTGgeslacht_vrouw . '", ' . '"' . $FTGid_ja . '", ' . '"' . $FTGid_nee . '", ' . '"' . $FTGdierarts_naam . '", ' . '"' . $FTGdierarts_praktijk . '", ' . '"' . $FTGdierarts_adres . '", ' . '"' . $FTGdierarts_plaats . '", ' . '"' . $FTGdierartsland . '", ' . '"' . $FTGdierartstelefoon . '", ' . '"' . $FTGdierartsmail . '"';
$dumpRecord = str_replace("\n", "\\n", $dumpRecord);
$dumpRecord = str_replace("\r", "\\r", $dumpRecord);
$dumpRecord = $dumpRecord . "\n";
$fileDump = "hondform.csv";
$fileHandle = fopen($fileDump, "a");
fwrite($fileHandle, $dumpRecord);
fclose($fileHandle);
# Redirect user to success page
header("Location: bedankt.php");
exit;
# End of PHP script
?>
1.137 views