dongwuwei0718 2016-09-09 20:07
浏览 61

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

So my user's have access to changing their custom notify which is stored in my 'clients' database as 'notify'. I cannot seem to find out how to pull this information per session (as I don't want another user to change someone else's notify. Basically I'm trying to allow the user to click "Change Notify" in the navigation menu, then their notify (which I am guessing will depend on their session ID) shows up in the notify textbox, which will allow them to edit it accordingly.

This is my session starting 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));
    }
}

?>

This is my update notify 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>
        ';
    }
}
?>

This is my Custom Notify Form

    <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>

Any help would be appreciated.

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 BP神经网络控制倒立摆
    • ¥20 要这个数学建模编程的代码 并且能完整允许出来结果 完整的过程和数据的结果
    • ¥15 html5+css和javascript有人可以帮吗?图片要怎么插入代码里面啊
    • ¥30 Unity接入微信SDK 无法开启摄像头
    • ¥20 有偿 写代码 要用特定的软件anaconda 里的jvpyter 用python3写
    • ¥20 cad图纸,chx-3六轴码垛机器人
    • ¥15 移动摄像头专网需要解vlan
    • ¥20 access多表提取相同字段数据并合并
    • ¥20 基于MSP430f5529的MPU6050驱动,求出欧拉角
    • ¥20 Java-Oj-桌布的计算