I have this serverConnect.php, I need to register the user email, but the @ and the words behind the @ are invisibles? here is the preg_match ‘/[^@.a-z_-0-9\s]/i’
How i can fix that, here is the code
<?php
function Connect(){
//Set global variables so they can be used in this function
global $hostName; global $userName;
global $password; global $database;
$status = mysql_connect($hostName,$userName,$password); //Attempt to connect to Database
if(!$status){echo 'Server Not Found'; exit;} //Hosting Server not found
if(!@mysql_select_db($database)){echo 'Database Not Found'; exit;} //Database not found
return $status; //Return link on established connection
}
function CheckKey($hash,$name){ //Check weather Md5 hash matches
global $secretKey;
$checkHash = md5($name.$secretKey);
if(strcmp($checkHash,$hash) == 0){
return 'pass'; //hash matches
}else{
return 'fail'; //hash failed
}
}
function CleanInput($input){ //Sanitize user input
$cleanInput = mysql_real_escape_string($input); //Use string escape
if(preg_match('/[^@.a-z_\-0-9\s]/i',$cleanInput) == 1){ // Using regular expression
echo 'Bad Input ==> ' . $input; exit; //Failed, exit to prevemt sql injection hacks
}
return $cleanInput; //Return clean input
}
?>