Jump to content

isset?


Nodral

Recommended Posts

Hi

 

I have a form which requires 5 values prior to submission.  I need to run an isset to establish whether all the fields are complete, which I can do.  I also need to run an !isset to establish if none of the fields are complete, which again I can do.  However, how do I establish whether only some of the fields are complete to return a message that there is missing information from the form?

Link to comment
Share on other sites

isset will return TRUE for a form field that contains an empty string, so you won't get the results you're expecting if you use it. You'd be much better off trimming the data from the incoming fields, and making sure they meet certain minimum and max length criteria with strlen, or that the values are within a specified range if applicable. Store validation errors in an array, then if the array isn't empty display the errors to the user along with the pre-populated form for corrections to be made.

 

 

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.