Publishing System Settings Logout Login Register
reloading a page using PHP
TutorialCommentsThe AuthorReport Tutorial
Tutorial Avatar
Rating
Add to Favorites
Posted on January 7th, 2008
135117 views
PHP Coding
We are going to create a page reload using PHP. Now if you're not sure if PHP works on your web host, then create a .php page and type in the following code:

 <?php echo "Hello World!"; ?> 


That should tell you if your web host provides PHP or not. Most servers do, some free ones do not.


Getting started, we first will write our variables for this script:

<?php

$page = $_SERVER['PHP_SELF']; // you can get rid of $_SERVER['PHP_SELF']; and replace it with your own link. e.x: $page = "demo.html";

?>


In this tutorial, we will be using the famous, header(); function.... I will show you a few other ways of reloading a page as well....

<?php

// so far we have our page we want to reload so now lets actually get it to work...

$page = $_SERVER['PHP_SELF']; // you can get rid of $_SERVER['PHP_SELF']; and replace it with your own link. e.x: $page = "demo.html";

// bellow we will set an exact amount of seconds we want the page to reload...

$sec = "10"; // you can change this to however many seconds you want the page to reload..

header("Refresh: $sec; url=$page");

?>


And for all of you who do not have php, we will use the meta tag version...

<meta http-equiv="Refresh" content="10;url=demo.html">


That will reload you to DEMO.html lets do a reload that will reload the page we are currently at

<meta http-equiv="Refresh" content="10">


Simple huh? Now I will re-write the PHP script with out the comment tags for those who just like to copy and paste.

<?php

$page = $_SERVER['PHP_SELF'];

$sec = "10";

header("Refresh: $sec; url=$page");

echo "Watch the page reload itself!";

?>


Hope this was helpful to some new people :D
Dig this tutorial?
Thank the author by sending him a few P2L credits!

Send
derek.sullivan

This author is too busy writing tutorials instead of writing a personal profile!
View Full Profile Add as Friend Send PM
Pixel2Life Home Advanced Search Search Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Tutorial Index Publish Tutorials Community Forums Web Hosting P2L On Facebook P2L On Twitter P2L Feeds Pixel2life Homepage Submit a Tutorial Publish a Tutorial Join our Forums P2L Marketplace Advertise on P2L P2L Website Hosting Help and FAQ Topsites Link Exchange P2L RSS Feeds P2L Sitemap Contact Us Privacy Statement Legal P2L Facebook Fanpage Follow us on Twitter P2L Studios Portal P2L Website Hosting Back to Top