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 = "lucealmighty@hotmail.co.uk";
$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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.