I made a little system to sign up for an event. It all worked like a charm and just the way I wanted it. But when I checked it today all of a sudden the comfirmation email people get after signing up for the event wouldn't send anymore. Everything works the same way it did previously, but just the mails won't send anymore. I added a few things to my code and then it wouldn't send anymore.
I added the (!filter_var($email, FILTER_VALIDATE_EMAIL) to verify if the email adress was in the correct format. So if the email was not correct OR if the mail wasn't send for any other reason, you would be redirected to fail.html. Else, you will be redrected to succes.html. After redoing the changes and doublecheking everything I just don't manage to find what's wrong.. Anyone who can tell me what's wrong with the code?
<?php
$connect=mysqli_connect('xxxx','xxxxx','xxxxx','xxxxxx');
if(mysqli_connect_errno($connect))
{
echo 'Failed to connect';
}
// create a variable
$naam=$_POST['naam'];
$email=$_POST['email'];
$club=$_POST['club'];
$eten=$_POST['eten'];
$moment=$_POST['moment'];
$slapen=$_POST['slapen'];
$acro=$_POST['acro'];
$opmerkingen=$_POST['opmerkingen'];
$datum=$_POST['datum'];
$dateTime = new DateTime("now", new DateTimeZone('Europe/Brussels'));
$mysqldate = $dateTime->format("d-m-Y H:i:s");
//Execute the query
mysqli_query($connect,"INSERT INTO registered (`naam`,`email`,`club`,`eten`,`moment`,`slapen`,`acro`,`opmerkingen`) VALUES('$naam','$email','$club','$eten','$moment','$moment','$acro','$opmerkingen')");
//Mail sending function
$subject = 'Bevestiging inschrijving JWDW van ' . htmlspecialchars($_POST["naam"]);
$to = $_POST['email'];
$from = "xxxxxxx@hotmail.com";
//data
$msg = "<html>
<body>
xxxxxxxxxx
</center>
</body>
</html>";
//Headers
$headers = "MIME-Version: 1.0\r\n";
$headers .= "Content-type: text/html; charset=UTF-8\r\n";
$headers .= "From: <".$from. ">" ;
mail($to,$subject,$msg,$headers);
echo "Verwerken...";
if (!filter_var($email, FILTER_VALIDATE_EMAIL)or(mysqli_affected_rows($connect) < 0)){
echo '<script type="text/javascript">
window.location = "fail.html"
</script>';
echo mysqli_error ($connect);
} elseif (mysqli_affected_rows($connect) > 0){
echo '<script type="text/javascript">
window.location = "succes.html"
</script>';
}
?>
Thanks in advance!
Senne