从数据库中提取用户的ID号(取决于登录的用户)

时间:2016-09-09 20:07:27

标签: php mysql session

因此,我的用户可以更改自己的自定义通知,这些通知存储在我的客户端'数据库为'通知'。我似乎无法了解如何在每个会话中提取此信息(因为我不希望其他用户更改其他人的通知。基本上我试图让用户点击&#34 ;更改通知"在导航菜单中,然后他们的通知(我猜它将取决于他们的会话ID)显示在通知文本框中,这将允许他们相应地编辑它。

这是我的会话开始php

<?php
include "includes/settings.php";
include "includes/database.php";
if(!isset($_SESSION))
{
    session_start();

echo "Welcome=" . $_SESSION['id'];
}

if(!isset($_SESSION['username']))
{
    echo'
    <script language="javascript">
    window.location.href="index.php"
    </script>
    ';
}
$usersrow = mysqli_query($con, "SELECT COUNT(1) FROM `users`");
$user_row = mysqli_fetch_array($usersrow);
$user_total = $user_row[0];

$clients = mysqli_query($con, "SELECT COUNT(1) FROM `clients`");
$clients_row = mysqli_fetch_array($clients);
$clients_total = $clients_row[0];
$time_now = time("Y-m-d");

if(isset($_GET['deleteclient']))
{
    if($_GET['deleteclient'])
    {
        $id = strip_tags($_GET['deleteclient']);
        mysqli_query($con, "DELETE FROM `clients` WHERE `id` = '$id'") or die(mysqli_error($con));
    }
}

?>

这是我的更新通知php

<?php
if(isset($_POST['upduser']))
{
    $clientnotify = $_POST['notifyVal'];
    $update_now = mysqli_query($con, "UPDATE `clients` SET `notify`='$clientnotify' WHERE `notify` = '".$client_notify."'");
    if($update_now)
    {
        echo'<div class="row"><div class="col-md-12"><div class="alert alert-success">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">x</button>
        <strong>OK!</strong> Client successfully updated!.
        </div></div></div>';
        echo '<meta http-equiv="refresh" content="1;url="dashboard.php">';
    }
    elseif(!$update_now)
    {
        echo'<div class="row"><div class="col-md-12"><div class="alert alert-danger">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">x</button>
        <strong>Fail!</strong> Client not update, Try again!.
        </div></div></div>
        ';
    }
}
?>

这是我的自定义通知表单

    <div class="panel panel-info">
    <form method="POST">
        <div class="panel-heading">
            <h3 class="panel-title">SET CUSTOM NOTIFY</h3>
        </div>
        <div class="panel-body controls no-padding">
        <div class="row-form">
                <div class="col-md-3"><strong>Notify : </strong></div>
                <div class="col-md-9"><input type="text" required class="form-control" value = "<?php echo $client_notify; ?>" placeholder="Notify" name="notifyVal"/></div>
        </div>
        </div>
        <div class="panel-footer">
        <button class="btn btn-success" name="updnotify">Set Custom Notify</button>
        </div>
    </form>
</div>

任何帮助都将不胜感激。

0 个答案:

没有答案
相关问题