adamriley Posted April 25, 2010 Share Posted April 25, 2010 can someone tell me why this is not working the time is 18.20 What i expect it to do is header to the open page but it does not (notopen.php) index.php <?php if ( Date(G) >= 16 && Date(G) <= 20 ) { $reason = "Unknown"; } else { $reason = "Interact is not open it opens at 4.pm and closes at 8 pm"; } if ( $reason = "Interact is not open it opens at 4.pm and closes at 8 pm" ) { // interact not open header('Location: http://interact/Basic/Notopen.php?reason=closed'); } else { // interact is open header('Location: http://interact/Basic/open.php'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/199695-any-help-please/ Share on other sites More sharing options...
MartinGr Posted April 25, 2010 Share Posted April 25, 2010 On line: "if ( $reason = "Interact is not open it opens at 4.pm and closes at 8 pm" ) { " you assign value to $reason variable instead of comparing it. You need to use ==. Quote Link to comment https://forums.phpfreaks.com/topic/199695-any-help-please/#findComment-1048117 Share on other sites More sharing options...
Pikachu2000 Posted April 25, 2010 Share Posted April 25, 2010 This might be easier. It's definitely more compact. <?php date_default_timezone_set('America/Chicago'); // Change to correct time zone for your area. if ( date(G) >= 16 && date(G) <= 20 ) { header('Location: http://interact/Basic/open.php'); exit(); } else { header('Location: http://interact/Basic/Notopen.php?reason=closed'); exit(); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/199695-any-help-please/#findComment-1048232 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.