0

i need to write a piece of code so that when the counter reaches 500 hundred the user is directed to a limit hit page. or if it is under 500 hundred it directs the user to the page they wanted to go to. i have used if statement to ech thing out before but in need it to either direct or redirect the user.

if anyone knows were there is a tutorial on this then please post it here.

3
Contributors
2
Replies
3
Views
9 Years
Discussion Span
Last Post by buddylee17
0

im guessing that you are setting this count whenever the user does something that you are counting. in the beginning of the page couldnt you include a file that contains

if($count >= 500){
header("maxpage.php");
}

but then again i am not sure how or what you are counting.

0

Try putting this at the top of every page that you want the counter to increment. I think this is what you are asking.

<?php
session_start();
if(empty($_SESSION['counter'])){
//initialize the counter if empty
$_SESSION['counter']=1;
}
else{
//increment the counter if counter is set
$_SESSION['counter']++;
}
if($_SESSION['counter']>=500){
//redirect if counter >= 500
header('location:index.php');
}
?>
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.