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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.