Friday, March 23, 2012

PHP, refresh button

When you update your site layout using   PHP form, you may need to refresh browsers to see the effect. You can add a refresh button, or include in the form submission, i.e when you submit the form, the website refreshes too.

Below is the code for refresh the web page, PHP function  header("Refresh: $sec; url=$page"); is use for refreshing.

<form name="revisons" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<input type="submit" class="input-button" name="refresh" value="refresh" /></td>

 if (isset($_POST["refresh"])) {
$page = $_SERVER['PHP_SELF'];
$sec = "1";
//refresh in 1 second.
header("Refresh: $sec; url=$page");

No comments:

Post a Comment