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.

Recommended Answers

All 2 Replies

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.

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');
}
?>
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.