Jump to content

[SOLVED] STRLEN HELP


SilentQ-noob-

Recommended Posts

Does anybody know how to make the PHP code for and if statement using strlen, where, if a field in a form isnt filled out an error message appears.

 

so if the name field is empty it gives an error message.

if (strlen($_POST['name'] <= 1 )) {
echo "The Name field has not been filled out, or is too short";
include ("_form.php");
}
else {
echo " thanks for filling out our form" ; 
}

this is what I have, doesnt work though....any help would be appreciated! thanks,

 

-noob-

Link to comment
https://forums.phpfreaks.com/topic/60666-solved-strlen-help/
Share on other sites

if (strlen($_POST['name']) <= 1 ) {

 

Thanks, but I've tried changing it to this, but that isnt the problem. The way I wrote it seems to be the correct syntax- (the way you suggested causes an error). So I really dont know why it returns true, regardless of wheather I put something into the name field or not.

Link to comment
https://forums.phpfreaks.com/topic/60666-solved-strlen-help/#findComment-301823
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.