Golden Child Posted January 12, 2012 Share Posted January 12, 2012 Hello, I am completely new to php so please forgive me ahead of time. I am trying to create a link button on a website for a client that only directs to a certain external website on certain days and hours. Specifically, this is a web radio button that the client only wants to link to the web radio site when their live broadcast is on the air during certain hours on the weekend (i.e. Sundays 8-10 PM). Any other time, the client wants the web radio button to link to a default page since the web radio station plays unrelated music all other hours of the week. Does anyone know the best way to create such a time sensitive link for a button on a webpage? Thanks. Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 12, 2012 Share Posted January 12, 2012 The trick is that you do not need to change the link. Instead have the link point to a page that makes the determination as to what page to load. I would probably have the link ALWAYS point to the default page and implement logic at the top of that page to redirect to the radio site at the predetermined hours. $day = date('N'); //1 (for Monday) through 7 (for Sunday) $time = date('Gi'); //HoursMinutes (Hours in 24hour format) //Create condition to check if during radio broadcase //This example looks for Sat or Sun from 2pm - 4pm if( ($day==6 || $day==7) && $time>1400 && $time<1600) { //Redirect to radio broadcase header("Location: http://domain.com/broadcast/radio.php"); exit(); } //Default page content for when broadcast is not avail goes here Quote Link to comment Share on other sites More sharing options...
Golden Child Posted January 12, 2012 Author Share Posted January 12, 2012 So this php info would go right into the html? Sorry, I'm new to php. Quote Link to comment Share on other sites More sharing options...
Psycho Posted January 12, 2012 Share Posted January 12, 2012 No it would go into PHP code that would come before the output for the default page. I'm not going to try and teach you the basics of PHP in a forum post. If you don't even know how to implement PHP code into a page then you might want to ask someone who does to do this for you. 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.