I have an input field to enter an email address as follows:
<input type="email" name="email" id="email" title="E-mail(Format: email@example.com)">
I want to check the validity of this when user submits the email address. So i used this code:
<?php
$email =($_POST['email']);
if(!filter_var($email, FILTER_VALIDATE_EMAIL))
{
echo "E-mail is not valid";
}
else
{
echo "E-mail is valid"; }? >
But although i enter an email as 'someone@example' this will print 'email is valid'. How can i validate the emails with 'someone@example.com' format? That means the format and the need of '@' and '.com' ?