Reputation:
Consider the following url based on a sporting event happening in the future:
http://www.example.com/file.php?1615=Submit
The 1615 in the url is the eventid. Now after the event has finishedthe page should not be viewable anymore.
Thus my question is how do I stop user from viewing the page if event has expired? Would something like this be my most efficient option using the following logic:
Is there a more efficient way I can tackle this problem?
Upvotes: 3
Views: 68
Reputation: 1598
Here is a water down version of what I believe you would like to do, change as needed
$id = $_SERVER["REQUEST_URI"];
$id = substr($id,0,4); //here is your event_id
//query your database
$data = $conn->query('SELECT event_date from events WHERE event_id ="$id"')
//get date
foreach($data as $row) {
$event_date =($row);
}
$cur_date = date("Ymd");
if($cur_date>$date){
//do what you need to do
}
Upvotes: 3
Reputation: 686
What you're proposing should just be a good way to do this as any, what you can do is redirect them to a 404 page if you really want to give the impression that this event doesn't exist anymore. or redirect to the event page but with a big warning that the event has already expired.
Upvotes: 1