Once every refresh, there is a write operation, what should I do?

Source: Internet
Author: User
My PHP program is this: the user there is a submission form content, after the user submits the form, here to write it to the database:

if ($_POST[WB])
{
mysql_query ("INSERT INTO .....") ", $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 at this point, but when I do my own experiment, the form is written, but after the page is refreshed, it is written again. After each refresh of the page, there will be a write operation, what should I do?

(Even if I use a $_POST[WB after the write operation] = "" To clear this variable 0 is not possible, and then refresh or write).


Reply to discussion (solution)

Not quite understand the landlord's meaning. The landlord is not submitted with the form of submit?
Since the point button can be submitted, landlord and how to refresh it? On which page does it refresh?
The landlord can put the PHP processing statements in a single PHP file, as long as the form action point to this file is good.
Accepting post and submitting post are all very complex on the same page.

After submitting a header to jump to other pages, it is not afraid of refreshing.

Not quite understand the landlord's meaning. The landlord is not submitted with the form of submit?
Since the point button can be submitted, landlord and how to refresh it? On which page does it refresh?
The landlord can put the PHP processing statements in a single PHP file, as long as the form action point to this file is good.
Accepting post and submitting post are all very complex on the same page.

Is the "Refresh" button in the browser toolbar.
If you commit to another page, such as submit.php, how do you jump to index.php? (index.php content returned to the user after submission)
Also, submit to another page, and that cookie is still valid?

There may be cases where the form is re-submitted during browser refresh. Suggest landlord use other browser under test.

Cookies are stored locally, as long as there is a temporary directory of the browser and the expiration date is valid.
You should be asking the session, right? Session is valid before closing the page.

Submit can be written like this
echo "Add Success"
This will automatically return to index.

JS verification, if the value is empty, prompt out, the form will not be submitted.

Cookies are stored locally, as long as there is a temporary directory of the browser and the expiration date is valid.
You should be asking the session, right? Session is valid before closing the page.

Submit can be written like this
echo "Add Success"
This will automatically return to index.
Thank you! You have to use script for your method, I will not do it for the time being. I used the header statement in login.php and other files, jump to index.php, found that it can work properly. And will not repeat the submission, thank you!

Not quite understand the landlord's meaning. The landlord is not submitted with the form of submit?
Since the point button can be submitted, landlord and how to refresh it? On which page does it refresh?
The landlord can put the PHP processing statements in a single PHP file, as long as the form action point to this file is good.
Accepting post and submitting post are all very complex on the same page.
Thank! I found the submission page and the Accept submission page in the same file is indeed very complex. And it's easy to make such a problem. After listening to your suggestions, I put the login, submit, and other functions are separated out, using a PHP file alone, and then after the processing of these files, use the header jump back to index.php. Work very well.

Useful to study 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.