Workaround for returning content after a form submission error (PHP website), Form php_php Tutorial

Source: Internet
Author: User
Tags php form php website

Workaround for returning content after a form submission error (PHP website), form PHP


Returning content after a form submission error what to do now, let's analyze and solve this problem today.

Overview of the situation:

When you fill out the form information to submit a problem is that when the user fills in and submits the form, the program determines that it does not meet the requirements and returns, and returns the information that was filled out before the form is emptied. If you fill in the amount of information is not the matter, if the amount of information to fill more, this will directly hit the person to fill in the good mood. Therefore, the problem of resolving the content that is filled out after the form submission error is returned is an urgent problem to improve the user experience.
For this problem, the general summary of the following several situations:
(1) The page uses the Session_Start function, this function has a feature is to force the current page is not refreshed, the workaround is to add the following code after this function:

There are several other solutions that are preceded by the Session_Start

The above settings session will cause the seesion to appear cache, which causes the session information can not be updated when you apply to the session, for this reason, this article proposed the following several other solutions.
(2) using the header method to set the message header Cache-control, add the next segment code on the page:
Header (' Cache-control:private, Must-revalidate '); Support page Bounce, note that we cannot have any output before
(3) using the Session_cache_limiter method, add the next segment code to the page:
Session_cache_limiter (' Private, must-revalidate '); Note to write before the Session_Start method
Here are some additional notes for the Cache-control message header field:
CACHE-CONTROL Specifies the caching mechanism that requests and responses follow. Setting Cache-control in a request message or response message does not modify the caching process in another message processing process. the cache directives for the request 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 shared with the cache. This allows the server to simply describe a partial response message for the user, and this response message is not valid for another user's request.

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

No-store: used to prevent important information from being inadvertently released. Sending in the request message will make the request and response messages do not use the cache.

Max-age: indicates that the client can receive a response that has a lifetime of not greater than the specified time (in seconds).

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

Max-stale: indicates that the client can receive a response message that exceeds 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 encounter similar problems can be completely solved, especially to remind that this solution is only for the PHP site, can remember.

http://www.bkjia.com/PHPjc/1063231.html www.bkjia.com true http://www.bkjia.com/PHPjc/1063231.html techarticle a workaround for returning content after a form submission error (PHP Web site), form PHP form submission error After the return content disappears what to do now, analyze and solve this problem today ...

  • 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.