Support Forums
Need an If/Else Statement - Printable Version

+- Support Forums (https://www.supportforums.net)
+-- Forum: Categories (https://www.supportforums.net/forumdisplay.php?fid=87)
+--- Forum: Coding Support Forums (https://www.supportforums.net/forumdisplay.php?fid=18)
+---- Forum: PHP The Hypertext Preprocessor (https://www.supportforums.net/forumdisplay.php?fid=21)
+---- Thread: Need an If/Else Statement (/showthread.php?tid=3353)



Need an If/Else Statement - Grizzly - 12-05-2009

I need an if/else statement. I would like it to check to see if a countdown clock has reached 0. If it reaches 0 I want to cancel a login form and a registration link. The countdown script is an include on the login.php file. The variable that is called is $difference. This will probably be an include as well.


RE: Need an If/Else Statement - Gaijin - 12-05-2009

I don't really understand you, but is this what you are looking for!

PHP Code:
if($difference != 0) {
    
//cancel
}else{
   
//do things




RE: Need an If/Else Statement - Grizzly - 12-05-2009

Sent you a PM.

Something like
PHP Code:
if($difference != 0) {
//do nothing. Users can login and register all they want.
}else{
//Login and Activation are not allowed. Prints "Sorry, but the round is over. Please stand by while the admin restarts the game."


Or an easier way to do that if there is one.

Or maybe it will display the login if $difference != 0, else login form and registration link are not displayed, but the above message (or a different one if I edit it) is displayed.


RE: Need an If/Else Statement - Gaijin - 12-05-2009

As I've said in the PM, you should use the GET method.

But you could also do the same check when calling the login form and the register link.
And simply not show them if $diff... is 0.
But the user could then still login.


RE: Need an If/Else Statement - Spl3en - 12-06-2009

It exists differents manner to compare a date with another, i don't know if you already know it !

you can try something like this :

PHP Code:
function game_is_okay($todays_date){
    
$exp_date "2006-01-16"// You can read it from a file, or create it manually, i don't know...
    
$today strtotime($todays_date);
    
$expiration_date strtotime($exp_date);
    if (
$expiration_date $today) {
      return 
1;
    } 
    else { 
      return 
0;
    }
}

$date date("Y-m-d"); 
if (
game_is_okay($date)){
 
// Do the game !
}
else {
 
// echo "error ! please wait ...etc";




RE: Need an If/Else Statement - Grizzly - 12-10-2009

I'm going to have to put this bit on hold. The project that I was working on has been placed on hold while I try to promote a different game. Although, I may look into implementing this into the game I have now.