Emil_4 0 Newbie Poster

Hello,
So I have buttons on my site connected to a PHP code that updates the column "status" in "users" table with a value based on what button you press.
This is the PHP script for that:

<?php

include('functions.php');

$servername = "localhost";
$username = "root";
$password = "";
$dbname = "emildeveloping";

// Create connection
$conn = mysqli_connect($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
    die("Connection failed: " . mysqli_connect_error());
}

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

if (isset($_POST['108'])) {
$sql = "UPDATE users SET status = '10-8' WHERE id='".$id."'";
}

if (isset($_POST['107'])) {
    $sql = "UPDATE users SET status = '10-7' WHERE id='".$id."'";
    }

    if (isset($_POST['105'])) {
        $sql = "UPDATE users SET status = '10-5' WHERE id='".$id."'";
        }

        if (isset($_POST['1015'])) {
            $sql = "UPDATE users SET status = '10-15' WHERE id='".$id."'";
            }

            if (isset($_POST['1023'])) {
                $sql = "UPDATE users SET status = '10-23' WHERE id='".$id."'";
                }

                if (isset($_POST['1097'])) {
                    $sql = "UPDATE users SET status = '10-97' WHERE id='".$id."'";
                    }

                    if (isset($_POST['1042'])) {
                        $sql = "UPDATE users SET status = '10-42' WHERE id='".$id."'";
                        }

if (mysqli_query($conn, $sql)) {
    echo "Status was updated.";
    header( "refresh:2;url=index.php" );
} else {
    echo "Error: " . mysqli_error($conn);
}

mysqli_close($conn);
?>

And this is the HTML snippet with buttons:

 <form  method="post" action="status.php">
   <input type="submit" class="submit-108" name="108" value="10-8">
</form>

<form  method="post" action="status.php">
   <input type="submit" class="submit-107" name="107" value="10-7">
   </form>

   <form  method="post" action="status.php">
   <input type="submit" class="submit-105" name="105" value="10-5">
   </form>

   <form  method="post" action="status.php">
   <input type="submit" class="submit-1015" name="1015" value="10-15">
   </form>

   <form  method="post" action="status.php">
   <input type="submit" class="submit-1023" name="1023" value="10-23">
   </form>

   <form  method="post" action="status.php">
   <input type="submit" class="submit-1097" name="1097" value="10-97">
   </form>

 <form  method="post" action="status.php">
   <input type="submit" class="submit-1042" name="1042" value="10-42">
   </form>

This part works fine, the column gets updated and so on.
The thing is that I have a div on my site that have a php snippet in it that displays the data from the status column with session variable.
And this div dosen't update when I have updated the column status and refreshes the page?
How can I make this happen?
The HTML snippet for displaying the status column:

 <div id="status" class="status"><b>My Status: </b><font color="#6195ff"><?php echo $_SESSION['user']['status']; ?></div></font>

Best Regards Emil

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.