Every time a refresh is refreshed, a write operation is performed. what should I do? -Php Tutorial

Source: Internet
Author: User
Every time a refresh is refreshed, a write operation is performed. what should I do? My php program is like this: the user has a content to submit the form. after the user submits the form, write it to the database:

If ($ _ POST [wb])
{
Mysql_query ("insert ....... ", $ Connect );
$ _ POST [wb] = "";
}

I mean: when $ _ POST [wb] is not empty, it indicates that the user submitted the form and writes it to the database. However, when I tried it myself, after submitting the form, yes, but it will be written again after the page is refreshed. Every time the page is refreshed, a write operation is performed. what should I do?

(Even if I use $ _ POST [wb] = "" after the write operation, this variable cannot be cleared. refresh the variable and write it again ).


Reply to discussion (solution)

I don't quite understand what the landlord means. Didn't the poster use the form's submit to submit it?
Since the button can be submitted, how does the landlord refresh it? On which page does it refresh?
The landlord can put the php processing statement in a php file separately, as long as the form action points to this file.
It will be complicated to accept post and submit post on the same page.

After submission, add a header to jump to other pages, so you are not afraid to refresh the page.

I don't quite understand what the landlord means. Didn't the poster use the form's submit to submit it?
Since the button can be submitted, how does the landlord refresh it? On which page does it refresh?
The landlord can put the php processing statement in a php file separately, as long as the form action points to this file.
It will be complicated to accept post and submit post on the same page.

Is the "refresh" button in the toolbar of the browser.
If you submit data to another page, such as submit. php, how can you jump to index. php? (Because after submission, the content returned to the user is still index. php)
Also, if I submit the request to another page, will the cookie or something still work?

The browser may resubmit the form during the refresh process .. We recommend that you use another browser for testing.

Cookies are stored locally. they take effect if a temporary directory of the browser exists and it does not expire.
Should you ask about the session? The session is valid until the page is closed.

Submit can be written in this way.
Echo "the script window. location. href = '/index. php' script is successfully added."
In this way, the index is automatically returned.

In js verification, if the value is null, the prompt is displayed, and the form is not submitted.

Cookies are stored locally. they take effect if a temporary directory of the browser exists and it does not expire.
Should you ask about the session? The session is valid until the page is closed.

Submit can be written in this way.
Echo "the script window. location. href = '/index. php' script is successfully added."
In this way, the index is automatically returned.
Thank you! You must use a script for your method. I will not use it for the moment. I used the header statement in login. php and other files to jump to index. php, and found that it can work normally. It will not be submitted again. thank you!

I don't quite understand what the landlord means. Didn't the poster use the form's submit to submit it?
Since the button can be submitted, how does the landlord refresh it? On which page does it refresh?
The landlord can put the php processing statement in a php file separately, as long as the form action points to this file.
It will be complicated to accept post and submit post on the same page.
Thank you! I found that the submission page and acceptance page are indeed complicated in the same file. And it is easy to make such a problem. After listening to your suggestion, I separated the login, submission, and other functions and used a php file separately. after processing these files, I jumped back to the index using the header. php. Work well.

I am also a beginner.

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.