Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: required text in comments?  (Read 761 times)

sibas

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 451
    • www.simply4all.net
required text in comments?
« on: November 18, 2012, 02:17:27 pm »

Hello
how to make in comments not required text?
In function comment I try to change the number in strlen

Quote
if (isset($_POST['comment'])) {
$comment = cleanWords(trim($_POST['text']));
$comment = strlen($comment) > 0 ? clean(cleanXSS($comment)) : null;

but still got "Your comment was not sent"
Logged

nukpana

  • Hero Member
  • *****
  • Karma: 71
  • Posts: 663
Re: required text in comments?
« Reply #1 on: November 18, 2012, 04:14:30 pm »

So make it so anyone can submit a blank comment?
Logged

sibas

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 451
    • www.simply4all.net
Re: required text in comments?
« Reply #2 on: November 19, 2012, 07:38:14 am »

Yes, not need to fill any text,
any idea why strlen($comment) > 0 is not working?
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Re: required text in comments?
« Reply #3 on: November 19, 2012, 10:08:51 am »

strlen($comment) > 0
the above reqiures greater than zero strlen.
 try
strlen($comment) >= 0

although if you are accepting zero length comments, why even check for length (which is what strlen does)?
Logged
Of all the things I have lost, it is my mind that I miss the most.

sibas

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 451
    • www.simply4all.net
Re: required text in comments?
« Reply #4 on: November 19, 2012, 10:30:08 am »

I try it also like this

Code: [Select]
$comment = cleanWords(trim($_POST['text']));
$comment = strlen($comment) >= 0 ? clean(cleanXSS($comment)) : null;
//$comment = clean(cleanXSS($comment));

still got "Your comment was not sent"
Logged

philmoz

  • High flyer
  • ULTIMATE member
  • ******
  • Karma: 161
  • Posts: 1988
    • fiddle 'n fly
Re: required text in comments?
« Reply #5 on: November 19, 2012, 01:56:44 pm »

I try it also like this

Code: [Select]
$comment = cleanWords(trim($_POST['text']));
$comment = strlen($comment) >= 0 ? clean(cleanXSS($comment)) : null;
//$comment = clean(cleanXSS($comment));

still got "Your comment was not sent"

confirmed ;)
Now the issue appears to be when the var is empty (or null), regardless of minimal setting.
I haven't tracked down the exact reason for this yet. It is not DB related, as the text field there has default NULL, and can accept empty insert.

Quick workaround to try....
Code: [Select]
$comment = strlen($comment) != 0 ? clean(cleanXSS($comment)) : ' ';This will place a space into $comment, therefore not null.

Think I found it....
Quote
if ($ip == $_SERVER['REMOTE_ADDR'] && $comment && $name && $post_article_id  &&
          checkMathCaptcha() && $doublecheck == 1 && $ident == 1)
if this $ comment is not set (is empty or null), the if statement fails and directs to error page.
Tested by removing the var from this statement, and submitted empty comment....
Logged
Of all the things I have lost, it is my mind that I miss the most.

sibas

  • Sr. Member
  • ****
  • Karma: 23
  • Posts: 451
    • www.simply4all.net
Re: required text in comments?
« Reply #6 on: November 19, 2012, 02:00:21 pm »

yes just I find it! :)
thanks philmoz
Logged