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 6770245
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:17:21+00:00 2026-05-26T15:17:21+00:00

How can I ref-fill posted form data via PHP in the event of an

  • 0

How can I ref-fill posted form data via PHP in the event of an error. I have a contact form and the user enters a bunch of information and if one field doesn’t validate, he loses everything. How can I stop this from happening and make sure it is secure?

I’ve tried this, but believe I read somewhere it is not secure:

<input type="text" name="name" value="<?php echo $_POST['name']; ?>" />
  • 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-05-26T15:17:21+00:00Added an answer on May 26, 2026 at 3:17 pm

    One issue is that if $_POST['name'] contains a ", then the value can ‘escape’ out and rewrite the page content.

    Another is that with strict error checking switched on, accessing a non-existent array index will throw a Notice error.

    Here is one safe way of re-filling the form data:

    <input type="text" name="name" value="<?php echo isset($_POST['name']) ? htmlspecialchars($_POST['name']) : ''; ?>" />
    

    I would personally recommend handling form display and validation through a framework, like Zend_Form within the Zend Framework. (You won’t have to change everything else across just to use the form stuff) It makes writing safe and readable code much easier.

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

Sidebar

Related Questions

How can I hide ?ref string from users but pass it to php code
How can I get the sha ref of a commit on a certain day?
How can I calculate year in a nullable date? partial void AgeAtDiagnosis_Compute(ref int result)
HTML is <a>ref</a> I need to get <a>ref</a>text How can i do this? $('a').append('text')
We can offer to the user an easy way to add a page tab
I have a class. In c#, is there some way (which i can implement
Can I set a private property via reflection? public abstract class Entity { private
I am resorting to a horrible hack in order to fill a locked-down data
If I define a new ref class in C++/CLI, can I then use this
Can anyone give an example of the use of REF CURSOR from Oracle using

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.