Hi all
My script, or better said the script i created after getting help from the experts here works fine on itself, but i wanted to add email validation to it, which i have tried but it does not work the way i wanted. I had made it so that the user has to check a checkbox before the script wil execute, since the script and the form are on the same page, as someone outhere told me that bwas the best etc etc. But i also do not wish to execute it if no checkboxes were checked, that is, it may execute but i dont like to receive an empty email as you will understand, since that makes not much sense to me, and the script was perfect until i tried to combine it adding email validation. Here is my script, i have a terrible headache so i hope the script will explain what i mean, and what i was trying to do, im aware of making a mess out of this, and cannot even more tell how i started to be honest, so anyone being able to fix the mess i made from it, would be greatly appreciated
Fdehell
<?php
function CheckEmail($sender) {
$sender = $_POST['T1'];
$to = "mail@mail.com";
$subject = "mail";
$mailbody = "";
if (!ereg("[A-Za-z0-9_-]+\@[A
-Za-z0-9_-
]+\.[A-Za-
z0-9_-]+",
$sender)) {
echo "U dient een geldige email op te geven";
exit;
}
else {
}
}
if (isset($_POST['submit'])){
$checkarr = $_POST['chkb'];
foreach ($checkarr as $var) {
$mailbody .= ". $var.\n";
}
}
if (isset($_POST['agree'])) {
CheckEmail($sender);
mail($to, $subject, $mailbody, "From: $sender") or die ("Fout in script!");
}
?>
Start Free Trial