seba4 Posted September 16, 2008 Share Posted September 16, 2008 Hi i am kind of a starter in php, and i just get on one problem.Thats the code i am using for sending emails from page. <? $to = "sabi@opsa.si"; $from_header = "From: $from"; if($contents != "") { //send mail - $subject & $contents come from surfer input mail($to, $subject, $contents, $from_header); header("Location: $HTTP_REFERER"); } else { print("<HTML><BODY>Error, no comments were submitted!"); print("</BODY></HTML>"); }?> Code i want to add, that checks email input for right characters. function checkEmail($from_header) { if (!preg_match("/^( [a-zA-Z0-9] )+( [a-zA-Z0-9\._-] )*@( [a-zA-Z0-9_-] )+( [a-zA-Z0-9\._-] +)+$/" , $from_header)) { return false; } return true;} I hope someone can help me how could i connect this 2 codes, so code will first check email/simple check for characters.If email is right then it will send emailThx for help Link to comment Share on other sites More sharing options...
Jesdisciple Posted September 16, 2008 Share Posted September 16, 2008 Umm... Have you read the PHP tutorial yet? checkEmail($from); But this would be incorrect and never match: checkEmail($from_header); Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.