Solution to the problem of disappearing the content after the form is submitted (PHP site) _php Tips

Source: Internet
Author: User

The return content disappears after the form submits an error how to do, today to analyze and solve this problem.

Status Overview:

When you fill out a form information submission, you will encounter a problem is when the user fills out and submits the form, the program judge does not meet the requirements and return, the return of the form information filled out before the situation will be emptied. If fill in the amount of information is not indifferent, if the amount of information to fill more, this will directly blow to fill the message of the good mood of people. Therefore, the problem of resolving form submission errors after the return of the content to disappear is an imminent problem to improve the user experience degree.
for this kind of problem, summed up about the following several situations:
(1) The page uses the Session_Start function, which has a feature that forces the current page to not be refreshed, and the solution is to add the following code to this function:

Header ("Cache-control:private"); Note that your PHP program cannot have any output before the bank 

There are several other solutions that are added before the 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's effective period 
(' public '); As if not using session 

The setting session above will cause the seesion to appear caching phenomenon, thus cause when you apply to the session place to be possible to be unable to update the sessions information the question, for this reason, this article proposes the following several other solutions.
(2) Use header method to set message header Cache-control, add the following code to the page:
header (' Cache-control:private, Must-revalidate '); Support page bounce, note that the line can not have any output before
(3) using the Session_cache_limiter method, add the following code to the page:
Session_cache_limiter (' Private, must-revalidate '); Note to write before the Session_Start method
under the face of the Cache-control message header field to do a supplementary note:
Cache-control Specifies the caching mechanism that the request and response follow. Setting Cache-control in a request message or in a response message does not modify the caching process during another message handling process. the cache directives requested include No-cache, No-store, Max-age, Max-stale, Min-fresh, only-if-cached, and the instructions in the response message include public, private, No-cache, No-store, No-transform, Must-revalidate, Proxy-revalidate, Max-age. The instructions in each message have the following meanings:

Public : indicates that the response can be cached by any buffer.

Private: indicates that the entire or partial response message for a single user cannot be handled by the shared cache. This allows the server to simply describe a partial response message from the user, which is not valid for other users ' requests.

No-cache: indicates that a request or response message cannot be cached

No-store: used to prevent important information from being inadvertently released. Sending in a request message will not use caching for both request and response messages.

Max-age: indicates that the client can receive a response that is not longer than the specified time in seconds.

Min-fresh: indicates that the client can receive response times that are less than the current time plus a specified time.

Max-stale: indicates that the client can receive response messages that exceed the timeout period. If you specify a value for the Max-stale message, the client can receive a response message that exceeds the specified value for the timeout period.

After reading this article, you will be able to solve a similar problem, especially to remind that this solution is only for the PHP site, you can remember.

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.