Jump to content

Email Validation


ahazin

Recommended Posts

havng finally got my form working and sending correctly to my email address (with help from you guys ;) ) i was wondering how to go about validating the email address, i dont want anything to complicated, simply checking that there is an @ symbol in the address would b enough.  However if there is additional validating i could do that wouldnt be to hard to implement perhaps i will include it.

 

this is my code so far: 

 

*Note* i have 2 txt boxs called name_field and email_field  and a text area called message.

 

<?php 
$to = "[email protected]";
$subject = "Contact Us";
$name_field = $_REQUEST['name_field'] ;
$email_field = $_REQUEST['email_field'] ;
$message = $_REQUEST['message'] ;
$headers = "From: $email_field";
$body = "Name: $name_field \n E-Mail: $email_field \n Message:\n $message";
$sent = mail($to, $subject, $body, $headers) ;
if($sent)
{print "Your mail was sent successfully"; }
else
{print "We encountered an error sending your mail"; }
?>

 

I was wondering how i would go about implementing the email validation in this code.  I am a complete novice in this area and any help would be appreciated. 

 

Thanks.

Link to comment
https://forums.phpfreaks.com/topic/85957-email-validation/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.