then add dot ’.’ and at ’@’, isn’t it?
Here is a simple example so you can figure out.
Please remember, this works vise versa, so you must think reverse way for your case:
<?php
/*
* to check the valid characters in names
* TRUE means BAD!
*/
private function _has_bad_char($characters) {
$bad_chars = array (
"U+0000", "/", "\\", ":", "*", "?", "'", "\"", "<", ">", "|", ";"
, "@", "=", "#", "&", "!", "*", "'", "(", ")", ",", "{", "}", ","
, "^" , "~" , "[" , "]" , "`"
);
foreach ($bad_chars as $bad_char) {
if (strstr($characters, $bad_char)) return TRUE;
}
}
The usage is:
<?php
if ($this->_has_bad_char($_POST['name'])) { // I use class in this case
echo $lng['badchars'];
return false;
}
EDIT: found my email validation script here
<?php
function check_email_address($email) {
if (!preg_match("/^([a-zA-Z0-9])+([\.a-zA-Z0-9_-])*@([a-zA-Z0-9_-])+(\.[a-zA-Z0-9_-]+)*\.([a-zA-Z]{2,6})$/", $email)) {
return false;
}
return true;
}
<?php
if(check_email_address($e) == FALSE) {
$_report .= '<h2>'.$lng['email_err'].'</h2>';
}