mercredi 3 août 2016

Content of IF statement still runs even when the statement evaluates too false

I have seen multiple posts on SO covering why an IF statement may run despite it evaluating, supposedly, to false - yet for me, it doesn't run anything inside the IF statement with the exception of a DELETE MySQL query. This is the code:

$placeOrderURL = 'placeOrderInitializer.php';
$payURL = 'pay.php';
$finalURL = 'finalProcessor.php';

$currentURL = basename($_SERVER['PHP_SELF']);

if($currentURL != $placeOrderURL && $currentURL != $payURL && $finalURL != $currentURL){

  $username = $_SESSION['user']['username'];

  $sql = "DELETE FROM tmpcontent WHERE username='$username'"; //Deletes the row
  mysqli_query($link,$sql);

  echo $username; //Doesn't output the username  
}

On a side not the SESSION and link to the database for the example are set -- and I have tried strict comparisons

Any help would be appreciated

Aucun commentaire:

Enregistrer un commentaire