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'); } ?> 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 ==. 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(); } ?> Link to comment https://forums.phpfreaks.com/topic/199695-any-help-please/#findComment-1048232 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.