I know that there is a ton of solutions to this problem but i need to validate email in a contact form.
this is my php mailer so far:
<?php if (isset($_POST['send'])){ $to = "[email protected]"; $subject = "new message"; $firstname = $_POST['name']; $email = $_POST['email']; $message = $_POST['message']; $headers = "From: $email"; $sent = mail($to, $subject, $message, $headers) ; if($sent) {echo "<script>alert('thanks for the message:) ');</script>"; }else {echo "<script>alert('sorry, message wasn't send');</script>"; } } ?> I have tried with filter_var
$result = filter_var( '[email protected]', FILTER_VALIDATE_EMAIL ); but, doesn't work.
If my way to sent mail through contact form isn't the "best practice way" feel free to correct me and send me on the right path :D
filter_varnot work?error_reporting(E_ALL);and check if there;s any error