Yes, you are absolutely right - just correct this part, as you said, changing it to
$email = mysql_real_escape_string($email, $link);
and it will protect against SQL injection there.
On the side of the note, I suggest using hash("sha512", xxx)instead md5, because MD5 is becoming obsolete. If your column size does not allow this, although you do not have the ability to change it, it is still OK.
source
share