Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7827729
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T10:00:51+00:00 2026-06-02T10:00:51+00:00

This might seem like a daft question but the sanitizing of user input continually

  • 0

This might seem like a daft question but the sanitizing of user input continually confuses me, and i would like once and for all to get a definitive answer.

So heres the scenario

  1. Customer fills in web form.
  2. PHP checks that the mandatory fields have been filled in appropriately, if not it doesn’t let the customer continue until they are.
  3. If so then the user input is displayed on screen for confirmation, while the input data is also stored as hidden form elements.
  4. Customer then confirms input, the hidden elements are then sent on for further processing.

Working with the principle that data shouldn’t be escaped until the last minute, how would this apply to the data stored in the hidden elements at point 3. (Obviously the data printed on screen at this point i have applied htmlentities() too)

Should i use htmlentities on the hidden elements, however this is technically not the last stage as after part 4 i would then be using the variables again before sticking them into a DB or email.

I am fully aware that i might be doing this completely wrong, so any thoughts are very welcome. ^_^

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T10:00:52+00:00Added an answer on June 2, 2026 at 10:00 am

    If you’re writing out the user’s input to the page, it should ALWAYS be escaped. Otherwise there’s nothing to stop people adding javascript etc to their input, or to try and escape out of your hidden fields and inject code onto the page. So yup, use htmlentities on the hidden fields too. Just because the user can’t see them doesn’t stop people from injecting code into them.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Note: This might seem like a Super User question at first, but please read
this might sound like a daft question but I can't seem to find a
This might seem like a stupid question but I have always wondered. What would
This might seem like a stupid question I admit. But I'm in a small
This might seem like a weird question, but bear with me. I'd like to
This might seem like a trivial question, but I'm a bit muddled in my
Ok sorry this might seem like a dumb question but I cannot figure this
This might sound like an obvious question but I can't seem to find the
This might seem like a silly question but valgrind doesn't by default give you
This might seem like a really dumb question, but I am writing an application

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.