Php reload page after updating record

Rated 3.92/5 based on 783 customer reviews

The best way to avoid this is to redirect the site visitor to a different page after you process the $_POST data.

So have your script process the form data, and then use header('Location: some/page.php') to redirect them to the success page.

Now on update here i want the page to be refresh so i could see the updated data, but here now if it update it's will keep user in edite page, and will show the data of privous entered if i see in database the data has been updated and if i refresh the page with f5 it will show the on edit page is been update with out that when i submit the form it will get update but on the form it will show the prevouse data, so how i can make the page to get refresh after submitting.

on redirection if if redirect to list page it will show that it's been updated, but here i want on mean time stay on edit page and reaload page so i could see the updated data.

are we talking about sync (you encounter a situation where you want to refresh during your php script is parsed) refrehs ( meta refresh would work fine) or about async continuous refresh of a page (more like javascript/ajax)?

Using 0 will continuously hammer your server, and/or your local cache, especially if you have images on the page.

If the the decision to refresh was made during the execution of the php code, then php certainly can refresh, and can choose after how many sec to [email protected], you can't consider as a feature of PHP, it is feature of HTML.

So In sort you are doing by setting html response header.

See here on how to do that: How to make a redirect in PHP?

Not all requirements makes this approach the best, but usually it allows for easier management as one page is for getting data and the other is for processing it.

This also makes additional options later easier too.

My problem is that once the post has been inserted into the database and the message has come up saying that it was successful it i refresh the page it will insert the same post again.

How can i also delete the post values so it does not do this?

Leave a Reply