Log in

View Full Version : random page every 500 clicks



dumbledory
08-04-2008, 12:35 AM
Hi,

I'm looking for a script that will basically load a different/unique page every X number of times a page is loaded. For example, I'll have users enter a password and the resultant page will load with a "Sorry, you are not a winner" message 499 times out of 500, and the other one instance would give the user a "Congratulations! You're a winner! Click here to complete the form with your name, address, etc." message.

I'm only using 500 as an example. It might be that I want 1 out of every 20 people/page loads to win.

Does anyone know of a script like this, or can anyone write one quickly that might serve this purpose?

Any help is greatly appreciated. :)

dumbledory
08-04-2008, 05:16 AM
alternatively, I need some sort of instant win script...

rangana
08-05-2008, 01:53 AM
20th viewer wins:


<?php
session_start();
$win=20; // 20th viewer will be the winner.
if(isset($_SESSION['views']))
{
$_SESSION['views'] = $_SESSION['views']+ 1;
echo 'Page Views = '.$_SESSION['views'];
if($_SESSION['views']==$win)
echo '<h1>Congratulations. You are the winner!</h1>';
}
else{
$_SESSION['views'] = 1;
echo 'Page View = 1';
}
?>


Hope it helps.