Support Forums

Full Version: Need an If/Else Statement
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
I don't really understand you, but is this what you are looking for!

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

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.
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.
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";

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.