Translating JavaScript into PHP?

Cathy V

New member
I'm trying to write a form validation script on the server side in case if spammers turn off JavaScript on their computer.

//Client side

var bad=new Array("bad","words","forbidden");

var input=document.formname.words.value;
for(var i=0;i<=bad.length-1;i++)
{
if(input.indexOf(bad)>=0)
{
alert("Forbidden words!");
return false;
}
}

//Server side
$bad=array("bad","words","forbidden");
$input=$_REQUEST['words'];
for($i=0;$i<=strlen($bad)-1;$i++)
{
if( I'm stuck here!!!!)
{
echo"Forbidden words!";
return false;
}
}

Can anyone give a hand with what I have to put in the "if condition" statement?

Many thanks.
 
Back
Top