samedi 25 juin 2016

How to execute both if and else blocks based on a condition into if-statement block?

I have a script like this:

if(isset($_SESSION["LoginValidation"]) && $_SESSION["LoginValidation"] == 1){

    $something = $db->prepare('SELECT cookie FROM users WHERE id = ?');
    $something->execute(array($_SESSION["Id"]));
    $num_row = $something->fetch();
    $_SESSION["cookie"] = $num_row['cookie'];

    if ( $_SESSION["cookie"] != $_COOKIE['login']) ){
        // jump to following else statement (outer else statement)
    }

} else {
    /* here - this block should be execute when
         - That inner if-statement is true
         OR
         - That outer if-statement is false
    */
}

As you see, I need to execute if-statement and if inner if-statement is true then execute else-statement. How can I do that?

Aucun commentaire:

Enregistrer un commentaire