homepage Welcome to WebmasterWorld Guest from 54.198.139.141
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
Subscribe to WebmasterWorld

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
Forum Library, Charter, Moderators: coopster & jatar k

PHP Server Side Scripting Forum

    
server-side maximum character limit for textarea?
ewwatson




msg:3619266
 5:01 pm on Apr 4, 2008 (gmt 0)

Hello everyone, I found a few methods but this stuff is still somewhat greek to me, so which do you guys prefer? Thanks!

$clipped_string=substr($_POST['textarea'],0,512);

or

<?
$position=14; // Define how many character you want to display.
$message="You are now joining over 2000 current";
$post = substr($message, 0, $position);
echo $post;
echo "...";
?>

or

$charLimit = 500;
if (strlen($_POST['desc']) <= $charLimit)
{
// do something
} else {
// do error
}

or

<?php
if (strlen($_POST['input']) > 300) {
// appropriate rejecting mechanism
} else {
// do what you want with it.
}
?>

 

MRaja




msg:3619280
 5:16 pm on Apr 4, 2008 (gmt 0)

Better to tell us what is the issue that you want to solve with this methods. the first, second, third & forth are good , every one for specific needs.

ewwatson




msg:3619314
 6:02 pm on Apr 4, 2008 (gmt 0)

Hello, I want to set a maximum amount of characters in my textarea on the server side. I already have this set on the client side. So I am just looking for the best method to add to my pre-existing formmail.php. Thanks!

coopster




msg:3619970
 6:25 pm on Apr 5, 2008 (gmt 0)

It depends on whether or not you want to clip the text at the last character in the middle of a word or not. If you don't care, then using substr [php.net] will be fine. If you want to make sure you don't clip a word you could use wordwrap [php.net].

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / PHP Server Side Scripting
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About
© Webmaster World 1996-2014 all rights reserved