mardi 20 juin 2017

Is it possible to compare session with sql?

I'm trying to use if statement by comparing $resultsub (pass by sql) and $_id (session). I have tried to use <> and == . It seem doesn't work. I think it have some error on my if statement. Please help me to correct my php code.

This is the code.

    <?php
include 'db_connect.php';

session_start(); 
$_id = $_SESSION['staff_id'];


if(isset($_POST['submit']))
{
    $sub_code = $_POST['sub_code'];
    $doc_name = $_POST['doc_name'];

    $checksub = "SELECT staff_id FROM subject WHERE sub_code='$sub_code' ";
    $resultsub = mysqli_query( $link,$checksub) or die("Query failed");

    if ($resultsub == $_id)
    {


      if((IsChecked('tick','delete')) && (IsChecked('tick','add')))
      {
           //some other code 

      }
    }

   else
     echo "you cannot upload file. Only coordinator for every subject only can upload file." ;


}


?>

It does not show any error. But it does not check my if statement and jump to else.

Aucun commentaire:

Enregistrer un commentaire