So I have this basic script:
/*check if email is valid*/
if (substr_compare ( $email , '@' , 0 )>0)
{
/*put user to temporary database*/
echo 'registration script';
}else{echo 'wrong mail';};
What I want to do is I want to check if string contains symbol ‘@’ (if mail is valid).
But it does not work:
when I set up variable $email to something like ‘name’ = the function returns ‘1’, though I assume it should return 0 or -1, as the letter is not there.
What am I missing?
To check if the sctring contains another substring you need to use
strpos(not compare function such assubstr_compare):And yes, the way you check for email address is pretty weak. Use regular expressions or built in PHP filters like