Forum Moderators: coopster
$maxlength = 20;
$string = $_POST['string'];
if([url=http://us2.php.net/manual/en/function.strlen.php]strlen[/url]($string) > $maxlength) {
$string = [url=http://us2.php.net/substr]substr[/url]($string, 0, $maxlength);
Good luck! :)
It's probably a fine solution to just use the maxLength attribute. If someone wants to intentionally remove the limit and enter more characters, then why not let them? I'm sure that the value is being checked (or limited by the DB) before it's stored.
I hate programmers
hehe...it's not our faults ;)
In case you decide to go with my little code snippet above, make sure to place a closing bracket at the end as I completely forgot to!