Jump to content

checking email


seba4

Recommended Posts

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

Archived

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

×
×
  • Create New...