Jump to content
Sign in to follow this  
son

Escape function issue for sticky form data

Recommended Posts

Have a form that is used to update, create or delete entries in db. All form fields sticky, but instead of echoing post data I echo values from variables. If update/delete form displays current db values in form field, if new entry they are empty to start off with, but will be sticky for those submissions where the field entries are filled out okay whilst others are not.

My issue now is that upon db submission I use:

$idesc = escape_data($_POST['idesc']);

which now causes the text to be escaped when there is an issue with another form field which is not what I want. What would be best? To move all escape_data bits till after the check that all form fields are filled out okay? Or is there a better alternative?

Son

Share this post


Link to post
Share on other sites

Escape the data just before using it in the database query. If you use prepared statements, escaping the data won't be needed at all.

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...