kimikai
03-10-2014, 08:41 PM
So I got myself through most of the code but I seem to have some problem with the final bits and pieces.
Right now it does everything its supposed to do, it gives error codes, it gives a thankyou message and it sends me a mail with all the content in it.
However... it only sends the content from the required fields. W/e I fill in data into the not required fields it wont show the data in the email. (It does show the prefix i give to the data i.e. php code being $content = 'Name: ' .$name . '\n'; it will show Name: but it wont show the information thats typed into the field with the parameter $name.
Could someone please tell me how i can make the PHP send me the information from the unrequired fields aswell?
Here's my code:
<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
if (isset($_POST['submit'])) {
$error = "";
if (!empty($_POST['ras'])) {
$ras = $_POST['ras'];
} else {
$error .= "- Klik het ras van uw hond aan. <br />";
}
if (!empty($_POST['kleur'])) {
$kleur = $_POST['kleur'];
} else {
$error .= "- Vul de kleur van uw hond in. <br />";
}
if (!empty($_POST['geslacht'])) {
$geslacht = $_POST['geslacht'];
} else {
$error .= "- Vul het geslacht van uw teef in. <br />";
}
if (!empty($_POST['naamhond'])) {
$naamhond = $_POST['naamhond'];
} else {
$error .= "- Vul de naam van uw hond in. <br />";
}
if (!empty($_POST['stamboom'])) {
$stamboom = $_POST['stamboom'];
} else {
$error .= "- Vul het stamboomnummer van uw hond in. <br />";
}
if (!empty($_POST['geboorte'])) {
$geboorte = $_POST['geboorte'];
} else {
$error .= "- Vul de geboortedatum van uw hond in. <br />";
}
if (!empty($_POST['klasse'])) {
$klasse = $_POST['klasse'];
} else {
$error .= "- Klik de gewenste klasse aan. <br />";
}
if (!empty($_POST['fokker'])) {
$fokker = $_POST['fokker'];
} else {
$error .= "- Vul de naam van de fokker in. <br />";
}
if (!empty($_POST['vader'])) {
$vader = $_POST['vader'];
} else {
$error .= "- Vul de naam van de vaderhond in. <br />";
}
if (!empty($_POST['moeder'])) {
$moeder = $_POST['moeder'];
} else {
$error .= "- Vul de naam van de moederhond in. <br />";
}
if (!empty($_POST['initialen'])) {
$initialen = $_POST['initialen'];
} else {
$error .= "- Vul uw initialen in. <br />";
}
if (!empty($_POST['eigachternaam'])) {
$eigachternaam = $_POST['eigachternaam'];
} else {
$error .= "- Vul uw achternaam in. <br />";
}
if (!empty($_POST['minitialen'])) {
$minitialen = "";
} else {
$minitialen = $_POST['minitialen'];
}
if (!empty($_POST['adres'])) {
$adres = $_POST['adres'];
} else {
$error .= "- Vul uw straatnaam in. <br />";
}
if (!empty($_POST['huisnr'])) {
$huisnr = $_POST['huisnr'];
} else {
$error .= "- Vul uw huisnummer in. <br />";
}
if (!empty($_POST['postcode'])) {
$postcode = $_POST['postcode'];
} else {
$error .= "- Vul uw postcode in. <br />";
}
if (!empty($_POST['woonplaats'])) {
$woonplaats = $_POST['woonplaats'];
} else {
$error .= "- Vul uw woonplaats in. <br />";
}
if (!empty($_POST['email'])) {
$email = $_POST['email'];
if (!preg_match("/^[_a-z0-9]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email)){
$error .= "- U heeft een ongeldig e-Mail adres ingevuld. <br/>";
}
} else {
$error .= "Vul uw e-Mail adres in. <br />";
}
if (!empty($_POST['akkoord'])) {
$akkoord = $_POST['akkoord'];
} else {
$error .= "- U moet akkoord gaan met de voorwaarden voordat u het bericht kunt versturen. <br />";
}
if (empty($error)) {
$from = 'From: ' . $eigachternaam . ' <' . $email . '>';
$to = "nabben.daisy@live.nl";
$subject = "Inschrijfformulier";
$content = $eigachternaam . " heeft een inschrijfformulier ingevuld: \n";
$content .= 'Ras: ' .$ras . "\n";
$content .= 'Kleur: ' .$kleur . "\n";
$content .= 'Geslacht: ' .$geslacht . "\n";
$content .= 'Naam v/d Hond: ' .$naamhond . "\n";
$content .= 'Geboortedatum: ' .$geboorte . "\n";
$content .= 'Klasse: ' .$klasse . "\n";
$content .= 'Kampioenstitel: ' .$kampioentitel . "\n";
$content .= 'Fokker: ' .$fokker . "\n";
$content .= 'Vaderhond: ' .$vader . "\n";
$content .= 'Moederhond: ' .$moeder . "\n";
$content .= 'Naam eigenaar: '.$initialen ;
$content .= $eigachternaam . "\n";
$content .= 'Naam mede-eigenaar: '.$minitialen ;
$content .= $meigachternaam . "\n";
$content .= 'Adresgegevens: ' .$straat ;
$content .= $huisnr ;
$content .= $postcode ;
$content .= $woonplaats ;
$content .= $land . "\n";
$content .= 'Telefoon: ' .$telefoon . "\n";
$content .= 'e-Mail: ' .$email . "\n";
$content .= 'Per Adres: ' .$peradres . "\n";
$content .= 'Eerste Hond: ' .$eerstehond . "\n";
$content .= 'Verdere Hond: ' .$verderehond . "\n";
$content .= 'Baby- Puppyklasse: ' .$babypup . "\n";
$content .= 'Koppelklasse: ' .$koppelklas . "\n";
$content .= 'Koppelklasse Hond 1: ' .$koppelhond1 . "\n";
$content .= 'Koppelklasse Hond 2: ' .$koppelhond2 . "\n";
$content .= 'Totaalbedrag: ' .$totaal . "\n";
$content .= 'Naam Juniorhandler: ' .$naamjh . "\n";
$content .= 'Leeftijd Juniorhandler: ' .$leeftijdjh . "\n";
$content .= 'Akkoord: ' .$akkoord . "\n";
$success = "Bedankt voor uw aanmelding!<br />We zullen de gegevens verwerken.<br />Papillon en Phalène Vereniging Nederland";
mail($to,$subject,$content,$from);
}
}
?>
Right now it does everything its supposed to do, it gives error codes, it gives a thankyou message and it sends me a mail with all the content in it.
However... it only sends the content from the required fields. W/e I fill in data into the not required fields it wont show the data in the email. (It does show the prefix i give to the data i.e. php code being $content = 'Name: ' .$name . '\n'; it will show Name: but it wont show the information thats typed into the field with the parameter $name.
Could someone please tell me how i can make the PHP send me the information from the unrequired fields aswell?
Here's my code:
<?php session_start(); ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="stylesheet.css" rel="stylesheet" type="text/css" />
</head>
<body>
<?php
if (isset($_POST['submit'])) {
$error = "";
if (!empty($_POST['ras'])) {
$ras = $_POST['ras'];
} else {
$error .= "- Klik het ras van uw hond aan. <br />";
}
if (!empty($_POST['kleur'])) {
$kleur = $_POST['kleur'];
} else {
$error .= "- Vul de kleur van uw hond in. <br />";
}
if (!empty($_POST['geslacht'])) {
$geslacht = $_POST['geslacht'];
} else {
$error .= "- Vul het geslacht van uw teef in. <br />";
}
if (!empty($_POST['naamhond'])) {
$naamhond = $_POST['naamhond'];
} else {
$error .= "- Vul de naam van uw hond in. <br />";
}
if (!empty($_POST['stamboom'])) {
$stamboom = $_POST['stamboom'];
} else {
$error .= "- Vul het stamboomnummer van uw hond in. <br />";
}
if (!empty($_POST['geboorte'])) {
$geboorte = $_POST['geboorte'];
} else {
$error .= "- Vul de geboortedatum van uw hond in. <br />";
}
if (!empty($_POST['klasse'])) {
$klasse = $_POST['klasse'];
} else {
$error .= "- Klik de gewenste klasse aan. <br />";
}
if (!empty($_POST['fokker'])) {
$fokker = $_POST['fokker'];
} else {
$error .= "- Vul de naam van de fokker in. <br />";
}
if (!empty($_POST['vader'])) {
$vader = $_POST['vader'];
} else {
$error .= "- Vul de naam van de vaderhond in. <br />";
}
if (!empty($_POST['moeder'])) {
$moeder = $_POST['moeder'];
} else {
$error .= "- Vul de naam van de moederhond in. <br />";
}
if (!empty($_POST['initialen'])) {
$initialen = $_POST['initialen'];
} else {
$error .= "- Vul uw initialen in. <br />";
}
if (!empty($_POST['eigachternaam'])) {
$eigachternaam = $_POST['eigachternaam'];
} else {
$error .= "- Vul uw achternaam in. <br />";
}
if (!empty($_POST['minitialen'])) {
$minitialen = "";
} else {
$minitialen = $_POST['minitialen'];
}
if (!empty($_POST['adres'])) {
$adres = $_POST['adres'];
} else {
$error .= "- Vul uw straatnaam in. <br />";
}
if (!empty($_POST['huisnr'])) {
$huisnr = $_POST['huisnr'];
} else {
$error .= "- Vul uw huisnummer in. <br />";
}
if (!empty($_POST['postcode'])) {
$postcode = $_POST['postcode'];
} else {
$error .= "- Vul uw postcode in. <br />";
}
if (!empty($_POST['woonplaats'])) {
$woonplaats = $_POST['woonplaats'];
} else {
$error .= "- Vul uw woonplaats in. <br />";
}
if (!empty($_POST['email'])) {
$email = $_POST['email'];
if (!preg_match("/^[_a-z0-9]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i", $email)){
$error .= "- U heeft een ongeldig e-Mail adres ingevuld. <br/>";
}
} else {
$error .= "Vul uw e-Mail adres in. <br />";
}
if (!empty($_POST['akkoord'])) {
$akkoord = $_POST['akkoord'];
} else {
$error .= "- U moet akkoord gaan met de voorwaarden voordat u het bericht kunt versturen. <br />";
}
if (empty($error)) {
$from = 'From: ' . $eigachternaam . ' <' . $email . '>';
$to = "nabben.daisy@live.nl";
$subject = "Inschrijfformulier";
$content = $eigachternaam . " heeft een inschrijfformulier ingevuld: \n";
$content .= 'Ras: ' .$ras . "\n";
$content .= 'Kleur: ' .$kleur . "\n";
$content .= 'Geslacht: ' .$geslacht . "\n";
$content .= 'Naam v/d Hond: ' .$naamhond . "\n";
$content .= 'Geboortedatum: ' .$geboorte . "\n";
$content .= 'Klasse: ' .$klasse . "\n";
$content .= 'Kampioenstitel: ' .$kampioentitel . "\n";
$content .= 'Fokker: ' .$fokker . "\n";
$content .= 'Vaderhond: ' .$vader . "\n";
$content .= 'Moederhond: ' .$moeder . "\n";
$content .= 'Naam eigenaar: '.$initialen ;
$content .= $eigachternaam . "\n";
$content .= 'Naam mede-eigenaar: '.$minitialen ;
$content .= $meigachternaam . "\n";
$content .= 'Adresgegevens: ' .$straat ;
$content .= $huisnr ;
$content .= $postcode ;
$content .= $woonplaats ;
$content .= $land . "\n";
$content .= 'Telefoon: ' .$telefoon . "\n";
$content .= 'e-Mail: ' .$email . "\n";
$content .= 'Per Adres: ' .$peradres . "\n";
$content .= 'Eerste Hond: ' .$eerstehond . "\n";
$content .= 'Verdere Hond: ' .$verderehond . "\n";
$content .= 'Baby- Puppyklasse: ' .$babypup . "\n";
$content .= 'Koppelklasse: ' .$koppelklas . "\n";
$content .= 'Koppelklasse Hond 1: ' .$koppelhond1 . "\n";
$content .= 'Koppelklasse Hond 2: ' .$koppelhond2 . "\n";
$content .= 'Totaalbedrag: ' .$totaal . "\n";
$content .= 'Naam Juniorhandler: ' .$naamjh . "\n";
$content .= 'Leeftijd Juniorhandler: ' .$leeftijdjh . "\n";
$content .= 'Akkoord: ' .$akkoord . "\n";
$success = "Bedankt voor uw aanmelding!<br />We zullen de gegevens verwerken.<br />Papillon en Phalène Vereniging Nederland";
mail($to,$subject,$content,$from);
}
}
?>