How to retrieve the firstname from database using session - php

I want to display the firstname from database who login in my website - not the username of the user.
Here's a picture of my database so I already tried query but always complains about an undefined index
This is the navbar attendance only there's a another navbar too but I only example the attendance
navbar_attendance.php
<div class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><i class="icon-home icon-large"></i> Home</li>
<li><i class="icon-home icon-large"></i> Attendance Info</li>
<li><i class="icon-user icon-large"></i> Users</li>
<?php
include('dropdown.php');
?>
<li><i class="icon-book icon-large"></i> Books</li>
<li><i class="icon-group icon-large"></i> Member</li>
<li ><i class="icon-list-alt icon-large"></i> Archive</li>
<li><i class="icon-cog icon-large"></i> Utilities</li>
<li><i class="icon-signout icon-large"></i> Logout</li>
</ul>
<div class="pull-right">
<div class="admin">Welcome: <?php
if(isset($_SESSION['id'])){
// dont know what put in here
}
?></div>
</div>
</div>
</div>
</div>
</div>
<?php include('search_form.php'); ?>
session.php
<?php if(!isset($_SESSION)){
session_start();
} ?>
<?php
if (!isset($_SESSION['id']) || (trim($_SESSION['id']) == '')) {
?> <script>window.location='index.php';</script> <?php
exit();
}
$session_id=$_SESSION['id'];
?>

Hi you need to put this query at the place where you want to show the first name.
<?php if(!isset($_SESSION)){
session_start();
} ?>
<div class="navbar navbar-fixed-top navbar-inverse">
<div class="navbar-inner">
<div class="container">
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</a>
<div class="nav-collapse collapse">
<ul class="nav">
<li><i class="icon-home icon-large"></i> Home</li>
<li><i class="icon-home icon-large"></i> Attendance Info</li>
<li><i class="icon-user icon-large"></i> Users</li>
<?php
include('dropdown.php');
?>
<li><i class="icon-book icon-large"></i> Books</li>
<li><i class="icon-group icon-large"></i> Member</li>
<li ><i class="icon-list-alt icon-large"></i> Archive</li>
<li><i class="icon-cog icon-large"></i> Utilities</li>
<li><i class="icon-signout icon-large"></i> Logout</li>
</ul>
<div class="pull-right">
<div class="admin">Welcome: <?php
if(isset($_SESSION['id'])){
$sql="SELECT firstname FROM TABLENAME WHERE user_id='$session_id'";
$result=mysqli_query($link,$sql);
if(mysqli_num_rows($result)>0)
{
while($row= mysqli_fetch_assoc($result)){
echo $row['firstname'];
}
}
}
?></div>
</div>
</div>
</div>
</div>
</div>
<?php include('search_form.php'); ?>`

Related

After clicking the submit button in a form, everything became undefined

Hi. Everything is working perfectly until I clicked the submit button.
This is what it looks like before clicking the submit button. But after clicking it, this is what it will look like. After clicking it, all the information became undefined. Can someone please help me.
I dont know what went wrong. Here is my code.
<?php
session_start();
if(!isset($_SESSION["user"]))
{
header("location:index.php");
}
ob_start();
include ('db.php');
$pid = $_GET['pid'];
$sql ="select * from reservation where reservationno = '$pid' ";
$re = mysqli_query($con,$sql);
while($row=mysqli_fetch_array($re))
{
$clientid = $row['clientid'];
$name = $row['name'];
$reservationno = $row['reservationno'];
$invoiceno = $row['invoiceno'];
$reservationdate = $row['reservationdate'];
$totalamount = $row['totalamount'];
$netamount = $row['netamount'];
$cin = $row['reservefrom'];
$cout = $row['reserveto'];
}
$asql ="select * from reservationdetails where reservationno = '$pid' ";
$are = mysqli_query($con,$asql);
while($row=mysqli_fetch_array($are))
{
$cout2 = $row['checkout2'];
$cout3 = $row['checkout3'];
$days = $row['days'];
$days2 = $row['days2'];
$days3 = $row['days3'];
$roomid = $row['roomid'];
$roomid2 = $row['roomid2'];
$roomid3 = $row['roomid3'];
$qty = $row['qty'];
$qty2 = $row['qty2'];
$qty3 = $row['qty3'];
}
?>
<div id="wrapper">
<nav class="navbar navbar-default top-navbar" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".sidebar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="home.php"><?php echo $_SESSION["user"]; ?> </a>
</div>
<ul class="nav navbar-top-links navbar-right">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
<i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i>
</a>
<ul class="dropdown-menu dropdown-user">
<li><i class="fa fa-user fa-fw"></i> User Profile
</li>
<li><i class="fa fa-gear fa-fw"> </i> Settings
</li>
<li class="divider"></li>
<li><i class="fa fa-sign-out fa-fw"></i> Logout
</li>
</ul>
<!-- /.dropdown-user -->
</li>
<!-- /.dropdown -->
</ul>
</nav>
<!--/. NAV TOP -->
<nav class="navbar-default navbar-side" role="navigation">
<div class="sidebar-collapse">
<ul class="nav" id="main-menu">
<li>
<i class="fa fa-dashboard"></i> Status
</li>
<li>
<i class="fa fa-desktop"></i> News Letters
</li>
<li>
<i class="fa fa-bar-chart-o"></i>Room Booking
</li>
<li>
<a class="active-menu" href="Payment.php"><i class="fa fa-qrcode"></i> Payment</a>
</li>
<li>
<i class="fa fa-qrcode"></i> Reports
</li>
<li>
</i> Logout
</li>
</div>
</nav>
<!-- /. NAV SIDE -->
<div id="page-wrapper" >
<div id="page-inner">
<div class="row">
<div class="col-md-12">
<h3 class="page-header">
Update Payment
</h3>
</div>
</div>
<!-- /. ROW -->`
<?php
include('db.php');
$mail = "SELECT * FROM `contact`";
$rew = mysqli_query($con,$mail);
?>
<div class="row">
<div class="col-md-12">
<div class="jumbotron">
<div class="panel-body">
<form>
<?php echo $clientid; ?><br>
<?php echo $name; ?><br>
Invoice no: <?php echo $invoiceno; ?><br>
Total Amount: ₱<?php echo $totalamount; ?><br>
Remaining Balance:
<br><br><br>
<h5>Payment: &nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp&nbsp<h5>
<input type="text" name="updatetextbox" /><br><br>
<h5>Confirm Payment:</h5>
<input type="text" name="updatetextbox1" />
<br>
<center><input type="submit" class="btn btn-primary" />
<?php
if(isset($_POST['submit'])){
$code1=$_POST['updatetextbox1'];
$code=$_POST['updatetextbox'];
if($code1!="$code"){
//$msg="Invalid code";
echo "<script type='text/javascript'> alert('Error')</script>";
}
else
$curdate=date("Y/m/d");
$paymentmode = "Cash";
$amountpaid_cash = 1.00;
$paymentdetails = "INSERT INTO `payments` (`clientid`, `name`, `reservationno`, `paymentmode`, `creditcardno`, `bankname`, `amountpaid_cc`, `amountpaid_cash`, `invoiceno`, `datepaid`) VALUES ('$clientid', '$name', '$reservationno', '$paymentmode', 'NULL', 'NULL', 'NULL', '$amountpaid_cash', '$invoiceno', '$curdate')";
if (mysqli_query($con,$paymentdetails))
{
echo "<script type='text/javascript'> alert('Your Booking application has been sent')</script>";
}
else
{
echo "<script type='text/javascript'> alert('Error adding user in database')</script>";
}
}
?>
</form>
</div>
</div>
</div>
<?php
$sql = "SELECT * FROM `contact`";
$re = mysqli_query($con,$sql);
?>
<!-- /. ROW -->
</div>
</div>
</div>
<!-- /. PAGE INNER -->
</div>
The problem is that you don't pass any of that information to the page after you submit it. Your first example shows pid as an HTTP get variable and that's what you use to define everything else. In your second example (after submit), there is no pid variable. Your code has no way to get the information unless you pass it along with the submit request or you include pid again, so that it can do the same lookup.
for those who came too late here is the answer to this question
you just need to put the insertion statement inside the :
This image will explain the solution
this happened because of the scope of the variables can't be reached outside the if statement block.

Navbar won't collapse Bootstrap v4.0.0-alpha.5

I'm working on a site with php header & footer in the html version works like a charmin but in the php the navbar don't return.
Here is my code header:
<div class="container">
<div class="row">
<div class="col-sm-3">
<div id="logo" class="float-xs-left">
<a class="navbar-brand" href="xxxxxxx/"><img src="img/logo-white.png" /></a>
</div>
</div>
<!--div class="col-sm-6" -->
<div class="float-xs-right">
<!--/div> -->
<!--cols:12 -->
<!--cols:12 -->
<div class="offcanvas">
<div class="navbar yamm col-lg-8 col-md-8 col-sm-6 ">
<div class="navbar-header">
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target=".offcanvas.menu">
<i class="fa fa-bars"></i>
<div class="line line-1"></div>
<div class="line line-2"></div>
<div class="line line-3"></div>
</button>
</div>
<!-- outside -->
<div class="offcanvas menu right">
<div class="navbar-collapse collapse">
<button data-target=".offcanvas.menu" data-toggle="collapse" class="navbar-toggle" type="button">
</button>
<div class="nav navbar-nav">
<div class="list-group">
<!-- li><span class="home">⌂</span></li -->
<img class="logo-img" src="img/logo-full.png" class="img-responsive" />
INICIO
home <b class="fa fa-chevron-down"></b>
<div class="collapse" id="p5">
<a href="page-1.php" class="list-group-item">
Espresso </a>
<a href="page-2.php" class="list-group-item">
Clásico </a>
<a href="page-3.php" class="list-group-item">
Orgánico </a>
<a href="page-4.php" class="list-group-item">
Descafeinado </a>
<a href="page-5.php" class="list-group-item">
Toscana </a>
</div>
<b class="fa fa-chevron-down"></b>
<div class="collapse" id="p6">
<a href="page-11.php" class="list-group-item">
</a>
</div>
<b class="fa fa-chevron-down"></b>
<div class="collapse" id="p4">
<a href="page-13.php" class="list-group-item">
item </a>
<a href="#c1" class="list-group-item" data-toggle="collapse">
another one<b class="fa fa-chevron-down"></b> <span class="cat_url" onclick="location.href='other.php'"><i class="fa fa-mail-forward"></i></span> </a>
<div class="collapse" id="c1">
name
name
name
name
name
</div>
<a href="#" class="list-group-item">
other page </a>
<a href="#" class="list-group-item">
other page </a>
<a href="#" class="list-group-item">
other page </a>
<a href="page-15.php" class="list-group-item">
other name </a>
<a href="page.php" class="list-group-item">
name </a>
<a href="page.php" class="list-group-item">
name </a>
<a href="#" class="list-group-item">
name </a>
</div>
page title <b class="fa fa-chevron-down"></b>
<div class="collapse" id="p7">
<a href="page-16.php" class="list-group-item">
Name </a>
<a href="page-17.php" class="list-group-item">
name </a>
</div>
page
</div>
<br/>
</div>
</div>
</div>
<!-- /.navbar-collapse -->
</div>
<div class="pusher"></div>
<!-- end outside -->
</div>
</div>
</div>
<!--cols:12 -->
<div class="navbar yamm ">
<div class="navbar-header hidden-lg-up">
<button type="button" class="navbar-toggler" data-toggle="collapse" data-target=".navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-toggleable-md collapse">
<ul class="nav navbar-nav">
<!-- li><span class="home">⌂</span></li -->
<li class="nav-item ">
<a href="contacto.php" >Contáctanos</a>
</li>
<li class="nav-item ">
</li>
</ul>
</div>
<!-- /.navbar-collapse -->
</div>
</div>
</div>
</div>
</header>
In the console get this error:
document.querySelector( "#nav-toggle" )
.addEventListener( "click", function() {
this.classList.toggle( "active" );
});
Does anybody know what the problem is and how I can fix it?
Solved
The issue was in the footer header and pages calling the same file so when the function is called the state doesn't return because repeat the action 3 times
Finally resolve the issue, there was a triple script sentence in the header, footer and index, was erased in the header and the footer and that's it.

Menu can't go directly to a page

I have menu which is has sub menus.
<li>
<i class="fa fa-flag-checkered" aria-hidden="true"></i> <span>Lead</span> <i class="icon-submenu lnr lnr-chevron-left"></i>
<div id="lead" class="collapse ">
<ul class="nav">
<li><i class="fa fa-quote-right" aria-hidden="true"></i><span> Quotation </span><i class="icon-submenu lnr lnr-chevron-left"></i>
<div id="quotation" class="collapse ">
<ul class="nav">
<li><i class="fa fa-dot-circle-o" aria-hidden="true"></i> Create Quotation</li>
<li><i class="fa fa-dot-circle-o" aria-hidden="true"></i> Quotation Summary</li>
<li><i class="fa fa-dot-circle-o" aria-hidden="true"></i> Send Quotation</li>
</ul>
</div>
</li>
</ul>
</div>
</li>
When I clicked it, I can not go directly to the page. I have to right-clicked on it to go to the desired page.
Here's an example of my controller
public function cquotation(){
$data = $this->salesModel->showCustomer();
$this->load->view('v_navbar');
$this->load->view('v_leftside');
$this->load->view('v_cquotation',array('data'=>$data));
}
Do you guys have any idea what's wrong with it?
I'm totally confused
Why are you using data-toggle="collapse" class="collapsed" on every hyperlink?. your code has data-toggle="collapse" class="collapsed" in every hyperlink.Bootstrap will prevent the default click event of a href .So remove every data-toggle="collapse" class="collapsed" part of a href in your code and it will work.
<li>
<i class="fa fa-flag-checkered" aria-hidden="true"></i> <span>Lead</span> <i class="icon-submenu lnr lnr-chevron-left"></i>
<div id="lead" class="collapse ">
<ul class="nav">
<li><i class="fa fa-quote-right" aria-hidden="true"></i><span> Quotation </span><i class="icon-submenu lnr lnr-chevron-left"></i>
<div id="quotation" class="collapse ">
<ul class="nav">
<li></i> Create Quotation</li>
<li></i> Quotation Summary</li>
<li></i> Send Quotation</li>
</ul>
</div>
</li>
</ul>
</div>
</li>

Hostinger error, Strict Standards Only variables should be passed by reference

<section class="vbox">
<header class="bg-dark lt header navbar navbar-fixed-top-xs">
<?php $uri = end( explode("/",$_SERVER['REQUEST_URI'])); ?>
<div class="navbar-header bg-dark aside-md"> <a class="btn btn-link visible-xs" data-toggle="class:nav-off-screen,open" data-target="#nav,html"> <i class="fa fa-bars"></i> </a> <img src="./files/logo.png" class="m-r-xs">ResidenConce <a class="btn btn-link visible-xs" data-toggle="dropdown" data-target=".nav-user"> <i class="fa fa-cog"></i> </a> </div>
<ul class="nav navbar-nav navbar-right nav-user m-n hidden-xs">
<li class="hidden-xs"> <i class="fa fa-bell"></i>
<section class="dropdown-menu aside-xl">
<section class="panel bg-white">
<header class="panel-heading b-light bg-light"> <strong>Tienes <span class="count">0</span> notificaciones</strong> </header>
</section>
</section>
</li>
<li class="dropdown"> <a href="#" class="dropdown-toggle" data-toggle="dropdown"> <span class="thumb-sm avatar pull-left"> <img src="./files/avatar.jpg"> </span> <?php if($_SESSION['logged_in']) { ?>
<?php echo $_SESSION['first_name']; ?> <b class="caret"></b> </a>
<ul class="dropdown-menu animated fadeInRight">
<span class="arrow top"></span>
<li> Ajustes </li>
<li class="divider"></li>
<li> Cerrar Sesión </li>
</ul>
</li>
</ul>
<?php } ?>
</header>
<section>
...
Gives me error in this line
<?php $uri = end( explode("/",$_SERVER['REQUEST_URI'])); ?>
In localhost it works, but in Hostinger it's the error
please any solution, thanks ind advance guys
end requires an array, not an expression resolved to array.
So:
<?php $uri = end( explode("/",$_SERVER['REQUEST_URI'])); ?>
should be:
<?php
$requestUriArray = explode("/",$_SERVER['REQUEST_URI'])
$uri = end($requestUriArray);
?>
end function has a parameter that passed by reference. So only need to use a variable to send this parameter:
$request_uri = explode("/",$_SERVER['REQUEST_URI']);
$uri = end($request_uri);

My login code loops me back instead of logging me in

I'm trying to make my system not able to go to my indextemplate.php (main page) without logging in first.
I've learned that $_SESSION is the perfect thing for it. However, I'm having quite a bit of problem with it.
Instead of logging me in, it just loops back to my index1.php (login page) without any error.
Here's my db code for my login page:
<?php
try {
$db = new PDO('mysql:host=localhost;dbname=login', "root", "");
} catch (PDOException $e) {
echo $e->getMessage();
}
$uid = $_POST['uid'];
$pwd = $_POST['pwd'];
$sql = "SELECT * FROM `user` WHERE `uid` = :uid AND `pwd` = :pwd";
$statement = $db->prepare($sql);
$userData = [
'uid'=>$uid,
'pwd'=>$pwd,
];
$statement->execute($userData);
if($statement->rowCount() > 0){
$_SESSION['logged'] = true;
header('Location: indextemplate.php');
exit();
}
elseif(empty($uid&$pwd)){
header('Location: index1.php?error=empty1');
exit();
}
elseif ($uid!=$idvariable&$pwd!=$idvarible){
header('Location: index1.php?error=empty2');
exit();
}
?>
and here's the code for my indextemplate (main page):
<?php
session_start();
if(!isset($_SESSION['logged'])){
header('location:index1.php');
}
else
{
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<?php include 'Header.php';
?>
</head>
<body>
<div id="wrapper">
<nav class="navbar navbar-default top-navbar" role="navigation">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data- toggle="collapse" data-target=".sidebar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="Indextemplate.php"><i class="fa fa-comments"></i><strong> JADE HOTEL </strong></a>
</div>
<ul class="nav navbar-top-links navbar-right">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
<i class="fa fa-envelope fa-fw"></i> <i class="fa fa-caret-down"></i>
</a>
<ul class="dropdown-menu dropdown-messages">
<li>
<a href="#">
<div>
<strong>John Doe</strong>
<span class="pull-right text-muted">
<em>Today</em>
</span>
</div>
<div>Lorem Ipsum has been the industry's standard dummy text ever since the 1500s...</div>
</a>
</li>
<li class="divider"></li>
<li>
<a href="#">
<div>
<strong>John Smith</strong>
<span class="pull-right text-muted">
<em>Yesterday</em>
</span>
</div>
<div>Lorem Ipsum has been the industry's standard dummy text ever since an kwilnw...</div>
</a>
</li>
<li class="divider"></li>
<li>
<a href="#">
<div>
<strong>John Smith</strong>
<span class="pull-right text-muted">
<em>Yesterday</em>
</span>
</div>
<div>Lorem Ipsum has been the industry's standard dummy text ever since the...</div>
</a>
</li>
<li class="divider"></li>
<li>
<a class="text-center" href="#">
<strong>Read All Messages</strong>
<i class="fa fa-angle-right"></i>
</a>
</li>
</ul>
<!-- /.dropdown-messages -->
</li>
<!-- /.dropdown -->
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
<i class="fa fa-tasks fa-fw"></i> <i class="fa fa-caret-down"></i>
</a>
<ul class="dropdown-menu dropdown-tasks">
<li>
<a href="#">
<div>
<p>
<strong>Task 1</strong>
<span class="pull-right text-muted">60% Complete</span>
</p>
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-success" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%">
<span class="sr-only">60% Complete (success)</span>
</div>
</div>
</div>
</a>
</li>
<li class="divider"></li>
<li>
<a href="#">
<div>
<p>
<strong>Task 2</strong>
<span class="pull-right text-muted">28% Complete</span>
</p>
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-info" role="progressbar" aria-valuenow="28" aria-valuemin="0" aria-valuemax="100" style="width: 28%">
<span class="sr-only">28% Complete</span>
</div>
</div>
</div>
</a>
</li>
<li class="divider"></li>
<li>
<a href="#">
<div>
<p>
<strong>Task 3</strong>
<span class="pull-right text-muted">60% Complete</span>
</p>
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-warning" role="progressbar" aria-valuenow="60" aria-valuemin="0" aria-valuemax="100" style="width: 60%">
<span class="sr-only">60% Complete (warning)</span>
</div>
</div>
</div>
</a>
</li>
<li class="divider"></li>
<li>
<a href="#">
<div>
<p>
<strong>Task 4</strong>
<span class="pull-right text-muted">85% Complete</span>
</p>
<div class="progress progress-striped active">
<div class="progress-bar progress-bar-danger" role="progressbar" aria-valuenow="85" aria-valuemin="0" aria-valuemax="100" style="width: 85%">
<span class="sr-only">85% Complete (danger)</span>
</div>
</div>
</div>
</a>
</li>
<li class="divider"></li>
<li>
<a class="text-center" href="#">
<strong>See All Tasks</strong>
<i class="fa fa-angle-right"></i>
</a>
</li>
</ul>
<!-- /.dropdown-tasks -->
</li>
<!-- /.dropdown -->
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
<i class="fa fa-bell fa-fw"></i> <i class="fa fa-caret-down"></i>
</a>
<ul class="dropdown-menu dropdown-alerts">
<li>
<a href="#">
<div>
<i class="fa fa-comment fa-fw"></i> New Comment
<span class="pull-right text-muted small">4 min</span>
</div>
</a>
</li>
<li class="divider"></li>
<li>
<a href="#">
<div>
<i class="fa fa-twitter fa-fw"></i> 3 New Followers
<span class="pull-right text-muted small">12 min</span>
</div>
</a>
</li>
<li class="divider"></li>
<li>
<a href="#">
<div>
<i class="fa fa-envelope fa-fw"></i> Message Sent
<span class="pull-right text-muted small">4 min</span>
</div>
</a>
</li>
<li class="divider"></li>
<li>
<a href="#">
<div>
<i class="fa fa-tasks fa-fw"></i> New Task
<span class="pull-right text-muted small">4 min</span>
</div>
</a>
</li>
<li class="divider"></li>
<li>
<a href="#">
<div>
<i class="fa fa-upload fa-fw"></i> Server Rebooted
<span class="pull-right text-muted small">4 min</span>
</div>
</a>
</li>
<li class="divider"></li>
<li>
<a class="text-center" href="#">
<strong>See All Alerts</strong>
<i class="fa fa-angle-right"></i>
</a>
</li>
</ul>
<!-- /.dropdown-alerts -->
</li>
<!-- /.dropdown -->
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#" aria-expanded="false">
<i class="fa fa-user fa-fw"></i> <i class="fa fa-caret-down"></i>
</a>
<ul class="dropdown-menu dropdown-user">
<li><i class="fa fa-user fa-fw"></i> User Profile
</li>
<li><i class="fa fa-gear fa-fw"></i> Settings
</li>
<li class="divider"></li>
<li><i class="fa fa-sign-out fa-fw"></i> Logout
</li>
</ul>
<!-- /.dropdown-user -->
</li>
<!-- /.dropdown -->
</ul>
</nav>
<!--/. NAV TOP -->
<nav class="navbar-default navbar-side" role="navigation">
<div id="sideNav" href=""><i class="fa fa-caret-right"></i></div>
<div class="sidebar-collapse">
<ul class="nav" id="main-menu">
<li>
<a class="active-menu" href="index.php"><i class="fa fa-dashboard"></i> Dashboard</a>
</li>
<li>
<i class="fa fa-bar-chart-o"></i> Charts
</li>
<li>
<i class="fa fa-table"></i> Database
</li>
<li>
<i class="fa fa-edit"></i> Forms
</li>
<li>
<i class="fa fa-fw fa-file"></i> Empty Page
</li>
</ul>
</div>
</nav>
<!-- /. NAV SIDE -->
<div id="page-wrapper">
<div id="page-inner">
<div class="row">
<div class="col-md-12">
<h1 class="page-header">
Dashboard
</h1>
<ol class="breadcrumb">
<li>Home</li>
<li>Library</li>
<li class="active">Data</li>
</ol>
</div>
</div>
<!-- /. ROW -->
<div class="row">
<div class="col-md-3 col-sm-12 col-xs-12">
<div class="panel panel-primary text-center no-boder bg-color-green green">
<div class="panel-left pull-left green">
<i class="fa fa-bar-chart-o fa-5x"></i>
</div>
<div class="panel-right pull-right">
<h3>8,457</h3>
<strong> Daily Visits</strong>
</div>
</div>
</div>
<div class="col-md-3 col-sm-12 col-xs-12">
<div class="panel panel-primary text-center no-boder bg-color-blue blue">
<div class="panel-left pull-left blue">
<i class="fa fa-shopping-cart fa-5x"></i>
</div>
<div class="panel-right pull-right">
<h3>52,160 </h3>
<strong> Sales</strong>
</div>
</div>
</div>
<div class="col-md-3 col-sm-12 col-xs-12">
<div class="panel panel-primary text-center no-boder bg-color-red red">
<div class="panel-left pull-left red">
<i class="fa fa fa-comments fa-5x"></i>
</div>
<div class="panel-right pull-right">
<h3>15,823 </h3>
<strong> Comments </strong>
</div>
</div>
</div>
<div class="col-md-3 col-sm-12 col-xs-12">
<div class="panel panel-primary text-center no-boder bg-color-brown brown">
<div class="panel-left pull-left brown">
<i class="fa fa-users fa-5x"></i>
</div>
<div class="panel-right pull-right">
<h3>36,752 </h3>
<strong>No. of Visits</strong>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
Line Chart
</div>
<div class="panel-body">
<div id="morris-line-chart"></div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-xs-6 col-md-3">
<div class="panel panel-default">
<div class="panel-body easypiechart-panel">
<h4>Customers</h4>
<div class="easypiechart" id="easypiechart-blue" data-percent="82" ><span class="percent">82%</span>
</div>
</div>
</div>
</div>
<div class="col-xs-6 col-md-3">
<div class="panel panel-default">
<div class="panel-body easypiechart-panel">
<h4>Sales</h4>
<div class="easypiechart" id="easypiechart-orange" data-percent="55" ><span class="percent">55%</span>
</div>
</div>
</div>
</div>
<div class="col-xs-6 col-md-3">
<div class="panel panel-default">
<div class="panel-body easypiechart-panel">
<h4>Profits</h4>
<div class="easypiechart" id="easypiechart-teal" data-percent="84" ><span class="percent">84%</span>
</div>
</div>
</div>
</div>
<div class="col-xs-6 col-md-3">
<div class="panel panel-default">
<div class="panel-body easypiechart-panel">
<h4>No. of Visits</h4>
<div class="easypiechart" id="easypiechart-red" data-percent="46" ><span class="percent">46%</span>
</div>
</div>
</div>
</div>
</div><!--/.row-->
<div class="row">
<div class="col-md-9 col-sm-12 col-xs-12">
<div class="panel panel-default">
<div class="panel-heading">
Bar Chart Example
</div>
<div class="panel-body">
<div id="morris-bar-chart"></div>
</div>
</div>
</div>
<div class="col-md-3 col-sm-12 col-xs-12">
<div class="panel panel-default">
<div class="panel-heading">
Donut Chart Example
</div>
<div class="panel-body">
<div id="morris-donut-chart"></div>
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
Area Chart
</div>
<div class="panel-body">
<div id="morris-area-chart"></div>
</div>
</div>
</div>
</div>
<!-- /. ROW -->
<div class="row">
<div class="col-md-4 col-sm-12 col-xs-12">
<div class="panel panel-default">
<div class="panel-heading">
Tasks Panel
</div>
<div class="panel-body">
<div class="list-group">
<a href="#" class="list-group-item">
<span class="badge">7 minutes ago</span>
<i class="fa fa-fw fa-comment"></i> Commented on a post
</a>
<a href="#" class="list-group-item">
<span class="badge">16 minutes ago</span>
<i class="fa fa-fw fa-truck"></i> Order 392 shipped
</a>
<a href="#" class="list-group-item">
<span class="badge">36 minutes ago</span>
<i class="fa fa-fw fa-globe"></i> Invoice 653 has paid
</a>
<a href="#" class="list-group-item">
<span class="badge">1 hour ago</span>
<i class="fa fa-fw fa-user"></i> A new user has been added
</a>
<a href="#" class="list-group-item">
<span class="badge">1.23 hour ago</span>
<i class="fa fa-fw fa-user"></i> A new user has added
</a>
<a href="#" class="list-group-item">
<span class="badge">yesterday</span>
<i class="fa fa-fw fa-globe"></i> Saved the world
</a>
</div>
<div class="text-right">
More Tasks <i class="fa fa-arrow-circle-right"></i>
</div>
</div>
</div>
</div>
<div class="col-md-8 col-sm-12 col-xs-12">
<div class="panel panel-default">
<div class="panel-heading">
Responsive Table Example
</div>
<div class="panel-body">
<div class="table-responsive">
<table class="table table-striped table- bordered table-hover">
<thead>
<tr>
<th>S No.</th>
<th>First Name</th>
<th>Last Name</th>
<th>User Name</th>
<th>Email ID.</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>John</td>
<td>Doe</td>
<td>John15482</td>
<td>name#site.com</td>
</tr>
<tr>
<td>2</td>
<td>Kimsila</td>
<td>Marriye</td>
<td>Kim1425</td>
<td>name#site.com</td>
</tr>
<tr>
<td>3</td>
<td>Rossye</td>
<td>Nermal</td>
<td>Rossy1245</td>
<td>name#site.com</td>
</tr>
<tr>
<td>4</td>
<td>Richard</td>
<td>Orieal</td>
<td>Rich5685</td>
<td>name#site.com</td>
</tr>
<tr>
<td>5</td>
<td>Jacob</td>
<td>Hielsar</td>
<td>Jac4587</td>
<td>name#site.com</td>
</tr>
<tr>
<td>6</td>
<td>Wrapel</td>
<td>Dere</td>
<td>Wrap4585</td>
<td>name#site.com</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<!-- /. ROW -->
<footer></footer>
</div>
<!-- /. PAGE INNER -->
</div>
<!-- /. PAGE WRAPPER -->
</div>
<?php include 'Scripts.php' ?>
</body>
</html>
<?php
}
?>
You need to start session when you are setting session variables.
if($statement->rowCount() > 0){
session_start();
$_SESSION['logged'] = true;
header('Location: indextemplate.php');
exit();
}
This will work.
Explanation : If you will not start session then $_SESSION['logged'] variable won't set itself value as true. So you need to start session before setting session variable. There is other solution like add session_start(); in top of page, but it's not good, because it will start session if user is not valid.
start session at the top of login code page.So that the value can be set to the session.
In your case, the session is not started,so it keeps looping to the same page
session_start();

Categories