Php form _ php Tutorial

Source: Internet
Author: User
Tags form post php form
Php form. The solution to the problem of data disappearance returned after the php form is submitted incorrectly. This article introduces the solution to the problem of data disappearance returned after the php form is submitted incorrectly, solution to the problem of data disappearance returned after the php form is submitted incorrectly. php form

This article introduces the solution to the problem of data disappearance returned after the php form is submitted incorrectly to the coders. For more information about coders, see.

What if the returned data disappears after the form is submitted incorrectly? let's analyze and solve this problem today.

Overview:

When submitting the form information, a problem occurs: After the user fills in and submits the form, the program determines that it does not meet the requirements and returns the result, the returned information is cleared. It doesn't matter if you fill in less information. if you fill in more information, this will directly hit the good mood of the person who fills in the information. Therefore, solving the problem that the content filled in after an error is returned after the form is submitted is an urgent issue to improve user experience.

For this problem, we have summarized the following situations:

(1) the session_start function is used on the page. this function forces the current page not to be refreshed. the solution is to add the following code after the function:

Header ("Cache-control: private"); // note that your PHP program cannot have any output before this line.

You can also add the following solutions before session_start:

Session_cache_limiter ('nocache'); // clear the form session_cache_limiter ('private'); // do not empty the form, only session_cache_limiter ('public') during the session takes effect '); // do not empty the form, as if no session is used

The preceding session settings will cause the seesion to be cached. as a result, when you apply the session, the session information cannot be updated. For this reason, this article provides the following solutions.

(2) use the Header method to set the message Header Cache-control and add the following code to the page:

Header ('cache-control: private, must-revalidate'); // page jump is supported. Note that no output is available before this line.

(3) use the session_cache_limiter method and add the following code to the page:

Session_cache_limiter ('private, must-revalidate'); // note that it should be written before the session_start method.

The following describes the Cache-Control Message header fields:

Cache-Control specifies the Cache mechanism that requests and responses follow. Setting Cache-Control in a request message or response message does not modify the Cache processing process of another message. The cache commands in the request include no-cache, no-store, max-age, max-stale, min-fresh, only-if-cached, commands in the response message include public, private, no-cache, no-store, no-transform, must-revalidate, proxy-revalidate, and max-age. The instructions in each message are as follows:

Public:Indicates that the response can be cached in any cache area.

Private:Indicates that the whole or part of the response message of a single user cannot be processed by the shared cache. This allows the server to only describe part of the user's response message, which is invalid for requests of other users.

No-cache:Indicates that the request or response message cannot be cached.

No-store:Used to prevent unintentional release of important information. Sending a request message does not cache the request and response messages.

Max-age:Indicates that the client can receive responses with a lifetime not greater than the specified time (in seconds.

Min-fresh:Indicates that the client can receive a response whose response time is earlier than the current time plus the specified time.

Max-stale:Indicates that the client can receive response messages beyond the timeout period. If the value of the max-stale message is specified, the client can receive response messages that exceed the timeout period.

After reading this article, you can thoroughly solve similar problems. I am particularly reminded that this solution is only applicable to php websites. remember it.

Address: http://www.manongjc.com/article/600.html

Related reading:

Php implements receiving multiple data instances with the same name but different values

Php obtains table data for instance sharing.

A complete php form verification instance

Php two ways to submit form

JQuery formValidator form verification

Jquery is a simple form verification example.

Php several methods to prevent repeated submission of forms

Js form onsubmit event usage details

Jquery is a complete example of no-refreshing ajax form submission.

Jquery uses ajax to submit form

Php uses curl to simulate post submission

Php uses fsockopen to simulate form post submission

Php form $ _ POST [] instance application

Share a common javascript method to verify whether the form is empty

Submit the php form to this page

Several methods for javascript to obtain form elements

A complete javascript form verification example

Use js to submit a form

Php form instance application

The solution to the problem of returning data disappears after submitting an error in the http://www.bkjia.com/PHPjc/1115253.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1115253.htmlTechArticlephp form. This article introduces the solution to the problem of returning data disappears after submitting an error in the php form to the coders, interested...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.