ahazin Posted January 14, 2008 Share Posted January 14, 2008 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 More sharing options...
revraz Posted January 14, 2008 Share Posted January 14, 2008 That is called Regular Expressions or REGEX. There are a ton of examples in the REGEX forum that shows you how to check for a [email protected] phrase. Link to comment https://forums.phpfreaks.com/topic/85957-email-validation/#findComment-438858 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.