contains
user profile menu (home, contact form, get details, search, update account and
logout) and unset session value and destroy session.
<?php
error_reporting(E_ALL);
include("config.php");
session_start();
if(isset($_REQUEST['log'])){
$log = $_REQUEST['log'];
//==============logout code
if ($log == "logout") {
unset($_SESSION['s_admin_id']);//unset session value
unset($_SESSION['s_username']);//unset session value
session_destroy(); //destroy session
header("location: login.php");
}}
$admin_id = $_SESSION['s_admin_id'];
$username = $_SESSION['s_username'];
if ($admin_id == "") { //if sesseion admin id NULL redirect to login.php
header("location: login.php");
}
$data = mysqli_query($con, "SELECT * FROM admin WHERE admin_id = '$admin_id'");//fetching all record from session admin id
$res = mysqli_fetch_array($data);
$name = $res['a_name'];
$email= $res['a_email'];
$name = strtoupper($name);
?>
<p>Welcome: <?php echo $name; ?></p> <!--display name of current admin login-->
<div class="menu">
<ul>
<?php echo'<li><a href="user.php?type='.$admin_id.'&username='.$username.'">Home</a>|</li>'?>
<?php echo'<li><a href="form.php?type='.$admin_id.'&username='.$username.'">Contact Form</a>|</li>'?>
<?php echo'<li><a href="showdetails.php?type='.$admin_id.'&username='.$username.'">Get Details</a>|</li>'?>
<?php echo'<li><a href="search.php?type='.$admin_id.'&username='.$username.'">Search</a>|</li>'?>
<?php echo'<li><a href="update.php?type='.$admin_id.'&username='.$username.'">Update Account</a>|</li>'?>
<?php echo'<li><a href="user.php?log=logout">LogOut</a></li>'?>
</ul>
</div>
<?php
error_reporting(E_ALL);
include("config.php");
session_start();
if(isset($_REQUEST['log'])){
$log = $_REQUEST['log'];
//==============logout code
if ($log == "logout") {
unset($_SESSION['s_admin_id']);//unset session value
unset($_SESSION['s_username']);//unset session value
session_destroy(); //destroy session
header("location: login.php");
}}
$admin_id = $_SESSION['s_admin_id'];
$username = $_SESSION['s_username'];
if ($admin_id == "") { //if sesseion admin id NULL redirect to login.php
header("location: login.php");
}
$data = mysqli_query($con, "SELECT * FROM admin WHERE admin_id = '$admin_id'");//fetching all record from session admin id
$res = mysqli_fetch_array($data);
$name = $res['a_name'];
$email= $res['a_email'];
$name = strtoupper($name);
?>
<p>Welcome: <?php echo $name; ?></p> <!--display name of current admin login-->
<div class="menu">
<ul>
<?php echo'<li><a href="user.php?type='.$admin_id.'&username='.$username.'">Home</a>|</li>'?>
<?php echo'<li><a href="form.php?type='.$admin_id.'&username='.$username.'">Contact Form</a>|</li>'?>
<?php echo'<li><a href="showdetails.php?type='.$admin_id.'&username='.$username.'">Get Details</a>|</li>'?>
<?php echo'<li><a href="search.php?type='.$admin_id.'&username='.$username.'">Search</a>|</li>'?>
<?php echo'<li><a href="update.php?type='.$admin_id.'&username='.$username.'">Update Account</a>|</li>'?>
<?php echo'<li><a href="user.php?log=logout">LogOut</a></li>'?>
</ul>
</div>
No comments:
Post a Comment