Ross2007 Posted January 22, 2007 Share Posted January 22, 2007 Hi All,I am using the following code to submit a form from flash and would like to incorporate email validation. I have looked at several methods on the web and am finding it confusing since I am relatively new to PHP, any help will greatly be appreciated.Kind RegardRoss[code]<?phpif(!empty($HTTP_POST_VARS['sender_mail']) || !empty($HTTP_POST_VARS['sender_message']) || !empty($HTTP_POST_VARS['sender_subject']) || !empty($HTTP_POST_VARS['sender_name'])){ $to = "[email protected]"; $subject = stripslashes($HTTP_POST_VARS['sender_subject']); $body = stripslashes($HTTP_POST_VARS['sender_message']); $body .= "\n\n---------------------------\n"; $body .= "Mail sent by: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n"; $header = "From: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n"; $header .= "Reply-To: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">\n"; $header .= "X-Mailer: PHP/" . phpversion() . "\n"; $header .= "X-Priority: 1"; if(@mail($to, $subject, $body, $header)) { echo "output=sent"; } else { echo "output=error"; }} else { echo "output=error";}?>[/code] Link to comment https://forums.phpfreaks.com/topic/35209-php-sendmail-email-form-validation/ Share on other sites More sharing options...
trq Posted January 22, 2007 Share Posted January 22, 2007 To start with (a little off topic) $HTTP_POST_VARS has long been depricated in favour of $_POST.Now, how do you want to validate the email? If you just want to validate that the form was filled in and that it contains a valid email format your probably best doing it within flash itself, as well as in php using [url=http://php.net/isset]isset[/url] and [url=http://php.net/preg_match]preg_match[/url].If you want to validate the email actually exists, you'll need to send it an email and ask the client to reply. Link to comment https://forums.phpfreaks.com/topic/35209-php-sendmail-email-form-validation/#findComment-166252 Share on other sites More sharing options...
Ross2007 Posted January 22, 2007 Author Share Posted January 22, 2007 Hi Thorpe,Thankyou for your fast reply, I want to beable to validate the email format, can you please help me with the PHP coding and maybe point me in the right direction for the action script coding.RegardsRoss Link to comment https://forums.phpfreaks.com/topic/35209-php-sendmail-email-form-validation/#findComment-166262 Share on other sites More sharing options...
trq Posted January 22, 2007 Share Posted January 22, 2007 [code=php:0]if(!empty($HTTP_POST_VARS['sender_mail']) || !eregi("^[a-zA-Z0-9_]+@[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-\.]+$]", $HTTP_POST_VARS['sender_mail']) || !empty($HTTP_POST_VARS['sender_message']) || !empty($HTTP_POST_VARS['sender_subject']) || !empty($HTTP_POST_VARS['sender_name']))[/code]Should be sufficient. then just change all instances of $HTTP_POST_VARS to $_POST. Link to comment https://forums.phpfreaks.com/topic/35209-php-sendmail-email-form-validation/#findComment-166274 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.