Forum Moderators: coopster
I'm trying to check for a couple strings in various input elements in one of my forms and if they exist send the user somewhere else to get rid of spamming. This is the code I have that does not work at present.
$reject = "string1";
$bad_url = "string2";
$bad_link = "string3";
$pos = strpos($_POST['email'], $reject);
$comments = $_POST['comments'];
$mess_url = strpos($comments, $bad_url);
$mess_link = strpos($comments, $bad_link);
if($pos === true ¦¦ $mess_url === true ¦¦ $mess_link === true )
{
header("Location:http://www.example.com", true);
exit();
}
Any help would be much appreciated.
Thanks!
Just to save you some reading, strpos() returns an interger (which represents the index of where the needle string is within the haystack string) or false of it doesn't exist within the haystack.
Your explicit comparison of '=== true' will never work as true is never returned.
Your best bet would be to do,
if($pos !== false ¦¦ $mess_url !== false ¦¦ $mess_link !== false) Hope this helps.
[edited by: Sekka at 11:17 am (utc) on Aug. 11, 2008]