mcpb Posted January 2, 2007 Share Posted January 2, 2007 I want to have a link or page expire at a set time.How can I do this with PHP?You know:You go to one link/pageAnd after the expired time you get redirected to another pageand can’t access the first page any more.. Its locked out or something..Thanks! Quote Link to comment Share on other sites More sharing options...
dcro2 Posted January 2, 2007 Share Posted January 2, 2007 Maybe use Javascript to time them, and then make a cookie? PHP is only a pre-processor. Quote Link to comment Share on other sites More sharing options...
AndyB Posted January 2, 2007 Share Posted January 2, 2007 Use the date function ...[code]<?php// has this expired?$expire_date = "2007-01-03"; // good until Jan 3/07$now = date("Y-m-d");if ($now>$expire_date) { header("Location: not_this_page.php"); die();}// and now the unexpired part of the page ...[/code] Quote Link to comment Share on other sites More sharing options...
mcpb Posted January 2, 2007 Author Share Posted January 2, 2007 Thanks Andy that does the trick!! Quote Link to comment Share on other sites More sharing options...
mcpb Posted January 2, 2007 Author Share Posted January 2, 2007 I was wondering if their might be a way to have a countdown timer showing till the link/page expires? Make sense? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted January 2, 2007 Share Posted January 2, 2007 That will have be doing in javascript which counts down. Quote Link to comment Share on other sites More sharing options...
mcpb Posted January 2, 2007 Author Share Posted January 2, 2007 well maybe someone will have a php answer as Andy had before... Quote Link to comment Share on other sites More sharing options...
taith Posted January 2, 2007 Share Posted January 2, 2007 this wont count down, you'd need javascript for that... but this'll show you how much time is left[code]<?$expires = strtotime("10 September 2007");if(time()>$expires) echo 'page expired';else{ $seconds = $expires-time(); while($seconds>15768000){ $seconds -=15768000; $years++; } while($seconds>43200){ $seconds -=43200; $days++; } while($seconds>3600){ $seconds -=3600; $hours++; } while($seconds>60){ $seconds -=60; $minutes++; } if(!empty($years)) $x .= ' '.$years.' years'; if(!empty($days)) $x .= ' '.$days.' days'; if(!empty($hours)) $x .= ' '.$hours.' hours'; if(!empty($minutes)) $x .= ' '.$minutes.' minutes'; $x .= ' '.$seconds.' seconds'; echo 'page exires in '.$x;}?>[/code] Quote Link to comment Share on other sites More sharing options...
Jessica Posted January 2, 2007 Share Posted January 2, 2007 If you want something to change after the page has loaded, you need javascript. It's okay, it doesn't bite too hard.I don't know if PHP can create animated gifs - I know it does gifs, but the animation I don't know about. The only other option I see is to make an animated gif counting down.Just use javascript ;) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.