Monday, July 16, 2012

URL Rotation php



URL Rotation php

This tutorial shows you changing URL in each 5 seconds select images 3 and name as image1,image2 and image3.
then create following 3 pages to be rotated(page5.php,page6.php and page7.php)


<?php
header('Refresh: 10; URL=page5.php');
session_start();
    // set timeout period in seconds
    $inactive = 500;
    // check to see if $_SESSION['timeout'] is set
    if(isset($_SESSION['timeout']) ) {
    $session_life = time() - $_SESSION['start'];
    if($session_life > $inactive)
    { session_destroy(); header("Location: page6.php"); }
    }
    $_SESSION['timeout'] = time();

?>
<img src="image1.jpg">
<?php
header('Refresh: 10; URL=page6.php');
session_start();
    // set timeout period in seconds
    $inactive = 500;
    // check to see if $_SESSION['timeout'] is set
    if(isset($_SESSION['timeout']) ) {
    $session_life = time() - $_SESSION['start'];
    if($session_life > $inactive)
    { session_destroy(); header("Location: page7.php"); }
    }
    $_SESSION['timeout'] = time();

?>
<img src="image2.jpg">
<?php
header('Refresh: 10; URL=page7.php');
session_start();
    // set timeout period in seconds
    $inactive = 500;
    // check to see if $_SESSION['timeout'] is set
    if(isset($_SESSION['timeout']) ) {
    $session_life = time() - $_SESSION['start'];
    if($session_life > $inactive)
    { session_destroy(); header("Location: page5.php"); }
    }
    $_SESSION['timeout'] = time();

?>
<img src="image3.jpg">

No comments:

Post a Comment