PHP Snippets

Name:Length Limit
Description: Check to see if a string reach a certain limit. Useful to avoid flood or other abuse.

Code below...
> <?php

  
//Text from a form
  
$message $_POST['field_name'];
  
//Count numbers of character
  
$mlen strlen($message);
  
//Maximum Length
  
$maxlen 300;
  
  
//Message length is greater than maximum length
  
if ($mlen $maxlen) { 
    echo 
"Message too long"
  }
  
//Message length is less than maximum length
  
else {
    echo 
"Good! Message received.";
  }

?>

« Back to PHP Snippets

Home | Site Map | Privacy Policy | Advertising | Contact Us
Copyright © 2006-2014 r2xDesign.net - All Rights Reserved.
eXTReMe Tracker