Note: I did scripting in perl/shell.. but not in Php.. So trying to understand a little bit more. As you can understand thats why I'm here....
I have a website in html for which I have a 'contact us' page, which contains email id field. Just before submitting.. am using this quick and simple PHP regular expression for quick email validation. But apparently this check is NOT working
Any help is much appreciated.
This is the php code am using
============
Code: Select all
<?php
$SendFormTo = 'sales@mycomp.com';
$Emailsubject = 'Contact us email from mycomp.com';
$Name = $_POST['Name'];
$Email = $_POST['Email'];
function verify_Email($Email)
{
if(!preg_match('/^[_A-z0-9-]+((\.|\+)[_A-z0-9-]+)*@[A-z0-9-]+(\.[A-z0-9-]+)*(\.[A-z]{2,4})$/',$Email))
{
return false;
} else
{
return $Email;
}
}
$Comments = $_POST['Comments'];
$body = "
Name - $Name
Email - $Email
Comments - $Comments
";
$headers = "From: $Email";
$success = mail($SendFormTo, $Emailsubject, $body, $headers);
header( "Location: http://www.mycomp.com" );
?>