Home > Blockchain >  Display application status for logged in users
Display application status for logged in users

Time:11-15

I have these codes in which i display some of the application form details to the users if they try to see their application status

(Application status page code)

<table class="table1">
<tr>
    <th>APPLICATION NUMBER</th>
    <th>SURNAME</th>
    <th>FIRST NAME</th>
    <th>DATE</th>
    <th>STATUS</th>
</tr>
<?php 
    //Query to get all admin

    $sql = "SELECT * FROM application ";

    //Execute the Query

    $res = mysqli_query($conn, $sql);

    //check weather query is executed

    if($res==TRUE){

      //count raws to check to check weather we have  data in database or not

      $count = mysqli_num_rows($res); //function to get all the raws in database

      $vb = 1; //create a variable & assign the value

      //check the number of raws

      if($count>0){

        //Data present in database

        while($rows=mysqli_fetch_assoc($res)){


          //Using while loop to get all the data from the database & will run as 
          //long as we have data in the databse

          //Get individual data

          $id=$rows['id'];
          $surname=$rows['surname'];
          $first_name=$rows['first_name'];
          $application_date = $rows['application_date'];
          $status = $rows['status'];
         
          

          //Display the values in our table

          ?>

    <tr>

    <td><?php echo $vb  ; ?></td>
    <td><?php echo $surname; ?></td>
    <td><?php echo $first_name; ?></td>
    <td><?php echo $application_date; ?></td>
    <td><?php echo $status; ?></td>

    </tr>

Now my question is how to display the application status details only for an user that is currently logged in, in the system.

CodePudding user response:

You can use PHP session variables for that. When the user is logging in, set the session variables.

// starting Session
session_start();

// setting session variables
$_SESSION["user_id"] = 12;
$_SESSION["user_name"] = "Jone Doe";

And then in your script, you can check if the session variables are set. If available, show the data.

if (isset($_SESSION["user_id"])){
    // Your PHP code for displaying data comes here
}

CodePudding user response:

If I'm understanding correctly your question, You can filter the query using WHERE clause OR have some relationship with your user table and application table.

User table Application
id id
username user_id
passwird status

then store the user id on the session when logging in.

$sql = "SELECT * FROM application WHERE user_id = $_SESSION['id']";
  • Related