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.