hi all,
looking for some advice on the best way to approach this:
i have a guestbook running on a few sites, and occasionally we get
"creative" people who think it's a good idea to post messages with really
long words or URLs into the text, which totally mess up the layout of the
page.
what I need is an efficient way of checking the input for extremely long
words (say about 60-odd characters +)
I assume I just split the input by " " (space) into an array, and check that
each "word" isn't longer than 60 chars, but this seems like a lot of work
for the server... although I am limiting the entire input to 2000 chars, so
maybe this isn't too much work for the server?
this is what I'm using:
<?
$word_length = 5;
$error = 0;
$str = "cat dog bird mouse elephant"; // illegal
$str = explode(" ", $str);
foreach($str as $key => $word)
{
if(strlen($word) > $word_length)
{ $error = 1; }
}
if($error)
{ echo "sorry"; }
else
{
$str = implode(" ", $str);
echo $str."<BR>";
}
?>
any ways to improve it?
Justin
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php