I've been reading trying to get a handle on how best to protect my database from malicious idiots who want to send poisoned email addresses. I am somewhat concerned that I just haven't read the right articles.
Is this code enough to protect the database?
if($_POST['coachEmail_ud'])
{
$transfer= protect($_POST['coachEmail_ud']); // load email from input
if(!filter_var($transfer, FILTER_VALIDATE_EMAIL))
{
$error['coachEmail_ud']="$alert Recheck email";
}
else {
$coachEmail = $transfer;
}
}
The function 'protect' offers the following:
function protect($string){
$string = mysql_real_escape_string($string);
return $string;
}
I'd appreciate any advice you may have.