Limit Number of Characters in Message

Helpdesk for my helpdesk software

Moderator: mkoch227

Post Reply
sun28fl
Posts: 4
Joined: Thu Mar 31, 2011 2:39 am

Limit Number of Characters in Message

Post by sun28fl »

Script URL:
Version of script: 2.2
Hosting company: GoDaddy
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution: limit

Write your message below:

I want to limit the number of characters that customers type in the Message box when submitting a ticket. I tried a solution I found in this forum (topic: "How To Stop People From Breaking Message Limit"), but it seems to have no effect - no error received if I exceed the limit.

In the submit_ticket.php file, I placed the following code below
"$question = hesk_input($_POST['question']);", then made the next IF statement, for "empty($question)", an elseif statement (just in case). What am I doing wrong here?

Code: Select all

if (strlen($question) > 300) 
{ 
hesk_error('Your message is too long, limit it to 300 chars.');
}
Thank you!
Klemen
Site Admin
Posts: 10145
Joined: Fri Feb 11, 2005 4:04 pm

Re: Limit Number of Characters in Message

Post by Klemen »

Textarea name is 'message' not 'question'
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
sun28fl
Posts: 4
Joined: Thu Mar 31, 2011 2:39 am

Re: Limit Number of Characters in Message

Post by sun28fl »

Thanks for that, Klemen!! That was definitely a key piece of info I was missing.

It works! Here's what I did:
Moved my bit of code outside of the 'question_use' IF statement, included the definition of the message variable (using the question section as my guide), and displayed the current character count if user runs over the limit (see code below).

I'm loving the Hesk Helpdesk software! :D
Thank you, Klemen for your quick and helpful reply!

Code: Select all

$message = hesk_input($_POST['message']);
	if (strlen($message) > 300) 
	{ 
		$hesk_error_buffer[]='Please limit your message to 300 characters. You currently have '.strlen($message).' characters in the message';
	}
Regards!
Post Reply