I 'wrote' my very first PHP script and I am rather proud of it 🙂
It's a form and it looks like this
<?
$mailto = "albruna@albruna.nl" ;
$subject = "Contactformulier" ;
$formurl = "http://www.albruna.nl/formulier.html" ;
$errorurl = "http://www.albruna.nl/fout.html" ;
$thankyouurl = "http://www.albruna.nl/dankuwel.html" ;
$name = $POST['name'] ;
$adress = $POST['adress'];
$place = $POST['place'];
$email = $POST['email'] ;
$comments = $_POST['comments'] ;
$http_referrer = getenv( "HTTP_REFERER" );
if (!isset($POST['email'])) {
header( "Location: $formurl" );
exit ;
}
if (empty($POST['name']) || empty($POST['email']) || empty($POST['comments'])) {
header( "Location: $errorurl" );
exit ;
}
$messageproper =
"This message was sent from:\n" .
"$http_referrer\n" .
"------------------------- opmerkingen -------------------------\n\n" .
"name:".$name . "\n".
"adress:".$adress . "\n".
"place:".$place . "\n".
"email:".$email . "\n".
$comments .
"\n\n------------------------------------------------------------\n" ;
mail($mailto, $subject, $messageproper, "From: \"$name\" <$email>\nReply-To: \"$name\" <$email>\nX-Mailer: chfeedback.php 2.01" );
header( "Location: $thankyouurl" );
exit ;
?>
It works great but what I really want to achive is that if an e-mail adress is not properly filled in it would go to the error page (fout.html). So if someone forgets the @ or the . it would send that person to the error page. Now it only does that if nothing has been filled in the e-mail field
But how I have looked at it and searched for tutorials and tried all sorts of different things I can't get it done.
Can anyone here explain to me how to tackle this 'problem'?
Greetings from a totall newbie to PHP.
Martin