display data added by user in sessions using leftjoin - php

i have managed to create a form whereby the user logs in using sessions and once the user is logged in ,he/she is able to post data into a different table named members.My problem is that I'm unable to retrieve the data added by the logged in user from the members table.I'm a newbie and i hope someone here will help me figure out this.below is my code
<!DOCTYPE html>
<?php
session_start();
if(!isset($_SESSION['phone'])){
header("location: login2.php");
}
else {
include ("../includes/db.php");
$sql = "select * FROM post";
$run = mysql_query($sql);
$total_post=mysql_num_rows($run);
$sql = "select * FROM gallary";
$run = mysql_query($sql);
$total_image=mysql_num_rows($run);
$sql = "select * FROM user";
$run = mysql_query($sql);
$total_user=mysql_num_rows($run);
$sql = "select * FROM course";
$run = mysql_query($sql);
$total_course=mysql_num_rows($run);
$sql = "select * FROM mails";
$run = mysql_query($sql);
$total_mails=mysql_num_rows($run);
?>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<title>Dashboard</title>
<!-- Bootstrap Core CSS -->
<link href="../bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
<!-- MetisMenu CSS -->
<link href="../bower_components/metisMenu/dist/metisMenu.min.css" rel="stylesheet">
<!-- Timeline CSS -->
<link href="../dist/css/timeline.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="../dist/css/sb-admin-2.css" rel="stylesheet">
<!-- Morris Charts CSS -->
<link href="../bower_components/morrisjs/morris.css" rel="stylesheet">
<!-- Custom Fonts -->
<link href="../bower_components/font-awesome/css/font-awesome.min.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="wrapper">
<!-- Navigation -->
<nav class="navbar navbar-default navbar-static-top" role="navigation" style="margin-bottom: 0">
<div class="navbar-header">
<button type="button" class="navbar-toggle" 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>
<a class="navbar-brand" href="index.php">Dashboard</a>
</div>
<!-- /.navbar-header -->
<ul class="nav navbar-top-links navbar-right">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">
<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-sign-out fa-fw"></i> Logout
</li>
</ul>
<!-- /.dropdown-user -->
</li>
<!-- /.dropdown -->
</ul>
<!-- /.navbar-top-links -->
<div class="navbar-default sidebar" role="navigation">
<div class="sidebar-nav navbar-collapse">
<ul class="nav" id="side-menu">
<li>
<i class="fa fa-dashboard fa-fw"></i> Dashboard
</li>
<!--
<li>
<i class="fa fa-edit fa-fw"></i> Create New Post
</li>
<li>
<i class="fa fa-table fa-fw"></i> View All Post
</li>
<li>
<i class="fa fa-edit fa-fw"></i> Create New Story
</li>
<li>
<i class="fa fa-table fa-fw"></i> View All Story
</li>
<li>
<i class="fa fa-edit fa-fw"></i> Upload Image
</li>
<li>
<i class="fa fa-photo fa-fw"></i> View All Image</span>
</li>
<li>
<i class="fa fa-photo fa-fw"></i> View All emails</span>
</li>
<li>
<i class="fa fa-edit fa-fw"></i> View All Joining members</span>
</li>
-->
</ul>
</div>
<!-- /.sidebar-collapse -->
</div>
<!-- /.navbar-static-side -->
</nav>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Dashboard</h1>
</div>
<!-- /.col-lg-12 -->
</div>
<!-- /.row -->
<div class="row">
<div class="col-lg-3 col-md-6">
<div class="panel panel-primary">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-list-ul fa-5x"></i>
</div>
<div class="col-xs-9 text-right">
<div class="huge"><?php echo $total_post; ?></div>
<div>All Posts!</div>
</div>
</div>
</div>
<a href="index.php?view_post=view_post">
<div class="panel-footer">
<span class="pull-left">View Details</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
<div class="clearfix"></div>
</div>
</a>
</div>
</div>
<div class="col-lg-3 col-md-6">
<div class="panel panel-green">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-photo fa-5x"></i>
</div>
<div class="col-xs-9 text-right">
<div class="huge"><?php echo $total_image; ?></div>
<div>All Images!</div>
</div>
</div>
</div>
<a href="images.php">
<div class="panel-footer">
<span class="pull-left">View Details</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
<div class="clearfix"></div>
</div>
</a>
</div>
</div>
<div class="col-lg-3 col-md-6">
<div class="panel panel-yellow">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-users fa-5x"></i>
</div>
<div class="col-xs-9 text-right">
<div class="huge"><?php echo $total_user; ?></div>
<div>All Users!</div>
</div>
</div>
</div>
<a href="users.php">
<div class="panel-footer">
<span class="pull-left">View Details</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
<div class="clearfix"></div>
</div>
</a>
</div>
</div>
<div class="col-lg-3 col-md-6">
<div class="panel panel-red">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-database fa-5x"></i>
</div>
<div class="col-xs-9 text-right">
<div class="huge"><?php echo $total_course; ?></div>
<div>All Story!</div>
</div>
</div>
</div>
<a href="course.php">
<div class="panel-footer">
<span class="pull-left">View Details</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
<div class="clearfix"></div>
</div>
</a>
</div>
</div>
<div class="col-lg-3 col-md-6">
<div class="panel panel-yellow">
<div class="panel-heading">
<div class="row">
<div class="col-xs-3">
<i class="fa fa-database fa-5x"></i>
</div>
<div class="col-xs-9 text-right">
<div class="huge"><?php echo $total_mails; ?></div>
<div>All mails!</div>
</div>
</div>
</div>
<a href="mails.php">
<div class="panel-footer">
<span class="pull-left">View Details</span>
<span class="pull-right"><i class="fa fa-arrow-circle-right"></i></span>
<div class="clearfix"></div>
</div>
</a>
</div>
</div>
</div>
<!--Post Section Open-->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">
<div class="panel-heading">
<h2>All users</h2>
</div>
<div class="panel-body">
<div class="dataTable_wrapper">
<table class="table table-striped table-bordered table-hover" id="dataTables-example">
<thead>
<tr>
<th>S.No.</th>
<th>Id</th>
<th>First_name</th>
<th>Last NAme</th>
<th>Email</th>
<th>phone</th>
<th>created</th>
<th>modified</th>
<th>status</th>
<th>Edit</th>
<th>Delete</th>
</tr>
</thead>
<?php
include("../includes/db.php");
$i=1;
$query="SELECT members.user_id,members.name,members.phone,members.location, user.username,user.phone
FROM members
LEFT JOIN user
ON members.user_id=user.phone
ORDER BY members.user_id;"
?>
<?php } ?>
</div>
</div>
</div>
</div>
</div>
</div>
<!--Post Section Close-->
</div>
<!-- /#page-wrapper -->
</div>
<!-- /#wrapper -->
<!-- jQuery -->
<script src="../bower_components/jquery/dist/jquery.min.js"></script>
<!-- Bootstrap Core JavaScript -->
<script src="../bower_components/bootstrap/dist/js/bootstrap.min.js"></script>
<!-- Metis Menu Plugin JavaScript -->
<script src="../bower_components/metisMenu/dist/metisMenu.min.js"></script>
<!-- Charts JavaScript -->
<script src="../bower_components/raphael/raphael-min.js"></script>
<script src="../bower_components/morrisjs/morris.min.js"></script>
<script src="../js/morris-data.js"></script>
<!-- Custom Theme JavaScript -->
<script src="../dist/js/sb-admin-2.js"></script>
</body>
</html>

You must join table with valid condition. I don't know your table structure for user table, as a guess i think this will help you.
$query="SELECT members.user_id,members.name,members.phone,members.location,
user.username,user.phone, user.id
FROM members
LEFT JOIN user
ON members.user_id=user.id
ORDER BY members.user_id;"

Related

I'm trying to display images using php while loop from the database, but it is not displaying in a row .what should I do?

I have used $row variable that contains database information and I want to repeat the div element with class
"col-md-3 col-sm-6" to repeat it self until the end of array.
I just want that every products details like product's image, name and price
should be display in one line and after 4 products it should display on the next line
<?php
$con = mysqli_connect("localhost","root","","grocerystore");
$sql = "SELECT * FROM main_products";
$result = mysqli_query($con,$sql);
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="style.css">
<title>Instamart Grocery Store</title>
</head>
<body>
<div class="navbar navbar-inverse">
<div class="container">
<div class="navbar-header">
Instamart Grocery
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="myNavbar"></button>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<ul class="nav navbar-nav navbar-right">
<!-- <li><span class="glyphicon glyphicon-log-in"></span> setting</li>
<li><span class="glyphicon glyphicon-log-in"></span> logout</li> -->
<li>
<div class="dropdown">
<button class="dropbtn"><span class="glyphicon glyphicon-user"></button>
<div class="dropdown-content">
<center>
<h4>
<?php echo $_SESSION['user_name'];?>
</h4>
</center>
Your Orders
Log-out
Change password
Your cart
</div>
</div>
</li>
</ul>
</div>
</div>
<div class="container">
<div class="jumbotron">
<h1>Let's be Healty together</h1>
<p>We have best choises of all products</p>
</div>
<div class="row">
<div class="col-md-3 col-sm-6">
<!-- <div class="thumbnail"> -->
<div class="caption">
<a href="dairy.php">
<h3><button class="btn btn-primary btn-block">Dairy Products</button></h3>
</a>
</div>
<!-- </div> -->
</div>
<div class="col-md-3 col-sm-6">
<!-- <div class="thumbnail"> -->
<div class="caption">
<div class="caption">
<h3 class="temp"><button class="btn btn-primary btn-block">Fresh Vegetable</button></h3>
</div>
</div>
<!-- </div> -->
</div>
<div class="col-md-3 col-sm-6">
<!-- <div class="thumbnail"> -->
<div class="caption">
<div class="caption">
<h3><button class="btn btn-primary btn-block">Fresh Fruits</button></h3>
</div>
</div>
<!-- </div> -->
</div>
<div class="col-md-3 col-sm-6">
<!-- <div class="thumbnail"> -->
<div class="caption">
<div class="caption">
<h3><button class="btn btn-primary btn-block">Daily Needs</button></h3>
</div>
</div>
<!-- </div> -->
</div>
</div>
</div>
<div class="container">
<div class="row row1">
<?php while($row = mysqli_fetch_array($result))
{
$image = $row['img_dir'];
?>
<div class="col-md-3 col-sm-6">
<div class="thumbnail">
<?php echo"<img src='{$image}'>";?>
<div>
<h3>
<?php echo $row['product_name'];?>
</h3>
<p>Price:
<?php echo $row['price'];?>
</p>
<a href="cart.php">
<button" class="btn btn-primary btn-block">Add to cart</button>
</a>
</div>
</div>
</div>
<?php } ?>
</div>
</div>
</body>
</html>
the images are displaying like this

Bootstrap side navbar doesn't work when I have includes (PHP)

My code works just fine if it is in html file, the header and footer codes are in the products page. The problem is if I make it in php file, the side navbar won't work, I already tried moving the body tag in the products page but it still doesn't work. Appreciate any help :)
header-ee.php
<html>
<head>
<?php
include('parameters.php');
?>
<title> <?php echo $page_title; ?> </title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="<?= $server_addr ?>/common/css/bootstrap.css">
<script src="<?= $server_addr ?>/common/js/jquery-3.2.1.js"></script>
<script src="<?= $server_addr ?>/common/js/bootstrap.js"></script>
<script src="js/ee-home.js"></script>
<link rel="stylesheet" href="css/ee-home.css">
</head>
<body data-spy="scroll" data-target="#myScrollspy" data-offset="20">
<!--Start header-->
<nav class="navbar navbar-default navigation-bar">
<div class="container-fluid">
<div class="row">
<div class="navbar-header col-xs-12 col-sm-12 col-md-12 col-lg-6 centered-a">
<div class="row">
<div class="col-sm-3 centered-a">
<img src="img/ee-logo.png">
</div>
<div class="col-sm-9">
<h1 id="nav-brand">
EQUIPMENT ENGINEERS, INC.</br>
</h1>
<h1 id="nav-brand-subtitle">
<small>
Your Reliable Solutions Partner
</small>
</h1>
</div>
</div>
<a href="#">
<span class="link-spanner"></span>
</a>
</div>
<div class="navbar-header col-lg-6 visible-lg centered-a">
<div class="row centered-a" id="nav-box">
<div class="col-lg-2 centered-a">
<a href="#">
<p>Home</p>
<span class="link-spanner"></span>
<a>
</div>
<div class="col-lg-2 centered-a">
<a href="#">
<p>Our Company</p>
<span class="link-spanner"></span>
<a>
</div>
<div class="col-lg-2 centered-a">
<a href="#">
<p>SCM</p>
<span class="link-spanner"></span>
<a>
</div>
<div class="col-lg-2 centered-a">
<a href="#">
<p>Products</p>
<span class="link-spanner"></span>
<a>
</div>
<div class="col-lg-2 centered-a">
<a href="#">
<p>Inquiries</p>
<span class="link-spanner"></span>
<a>
</div>
<div class="col-lg-2 centered-a" id="last-item">
<a href="#">
<p">Supplier Accreditation</p>
<span class="link-spanner"></span>
<a>
</div>
</div>
</div>
</div>
<div class="panel-group col-md-12 centered-a hidden-lg">
<div class="panel panel-default">
<div class="panel-heading" >
<h2 class="panel-title centered-a">
<span class="glyphicon glyphicon-triangle-bottom"></span>
<a data-toggle="collapse" href="#collapse1">
<span class="link-spanner"></span>
<a>
</h2>
</div>
<div id="collapse1" class="panel-collapse collapse">
<ul class="list-group">
<li class="list-group-item">
Home
<span class="link-spanner"></span>
</li>
<li class="list-group-item">
Our Company
<span class="link-spanner"></span>
</li>
<li class="list-group-item">
SCM
<span class="link-spanner"></span>
</li>
<li class="list-group-item">
Products
<span class="link-spanner"></span>
</li>
<li class="list-group-item">
Inquiries
<span class="link-spanner"></span>
</li>
<li class="list-group-item">
Supplier Accreditation
<span class="link-spanner"></span>
</li>
</ul>
</div>
</div>
</div>
</div>
</nav>
<!--End header-->
products.php
<?php include("includes/header-ee.php"); ?>
<link rel="stylesheet" href="products.css"></link>
<div class="container-fluid">
<div class="row">
<!--Sidebar-->
<nav class="col-md-3" id="myScrollspy">
<span>Product Lineup</span>
<ul class="nav nav-pills nav-stacked">
<li class="active">Section 1</li>
<li>Section 2</li>
<li>Section 3</li>
</ul>
</nav>
<!--Content-->
<div class="col-md-9">
<div id="section1">
<div class="bg-franklin bg-img centered-a">
<div class="caption" style="border:10px; border-color:white;">
<img src="img/products/franklin.png" style="width:50%; background-color:white;"></img>
</div>
</div>
<p style="margin-left:10px; margin-right:10px; font-size: 1.2em; text-align:left;padding: 0% 3%;">
</br>
</br></br>
</br></br>
</p>
</div>
<div id="section2">
<div class="bg-franklin bg-img centered-a">
<div class="caption" style="border:10px; border-color:white;">
<img src="img/products/franklin.png" style="width:50%; background-color:white;"></img>
</div>
</div>
<p style="margin-left:10px; margin-right:10px; font-size: 1.2em; text-align:left;padding: 0% 3%;">
</br>
</br></br>
</br></br>
</p>
</div>
</div>
</div>
</div>
<?php include("includes/footer-ee.php"); ?>
footer-ee.php
</body>
<footer>
<div class="footer-blk row">
<div style="float: none;text-align: center;">
Home | Terms and Conditions | Privacy Policy
</div>
<div style="float: none;text-align: center;">
</div>
</div>
</footer>

how can i pass my variable to my modal?

I'm having a hard time on passing my variable to my modal.
I can't simply pass my informant id to my modal and I really would want to use it for my query as my base to search for or compare it.
I don't know how to pass it like the URL passing of variable using GET function and I'm really new to this and just wanted to try modal unlike creating a new page for a summary.
Code:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=deviceADMIN | Missing Person Tracking System-width, initial-scale=1.0" />
<title>ADMIN | Missing Person Tracking System </title>
<!-- Bootstrap Styles-->
<link href="assets/css/bootstrap.css" rel="stylesheet" />
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<!-- FontAwesome Styles-->
<link href="assets/css/font-awesome.css" rel="stylesheet" />
<!-- Morris Chart Styles-->
<link href="assets/js/morris/morris-0.4.3.min.css" rel="stylesheet" />
<!-- Custom Styles-->
<link href="assets/css/custom-styles.css" rel="stylesheet" />
<!-- Google Fonts-->
<link href='http://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css' />
</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="index.php"><i class="fa fa-shield"></i> <strong>POLICE ADMIN </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-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-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>
<i class="fa fa-dashboard"></i> Dashboard
</li>
<li>
<i class="fa fa-user"></i> Missing Person Management
</li>
<li>
<i class="fa fa-plus"></i> Create Account</span>
</li>
<li>
<i class="fa fa-sitemap"></i> Manage Services <span class="fa arrow"></span>
<ul class="nav nav-second-level">
<li>
News
</li>
<li>
Contacts
</li>
</ul>
</li>
<li>
<a class="active-menu" href="#"><i class="fa fa-sitemap"></i> Transactions <span class="fa arrow"></span></a>
<ul class="nav nav-second-level">
<li>
<<a class="active-menu" href="transac_pending.php"> Pending</a>
</li>
<li>
Verified
</li>
<li>
Rejected
</li>
</ul>
</li>
<li>
<i class="fa fa-file"></i> Reports
</li>
<li>
<i class="fa fa-history"></i> Audit Trail
</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">
Transaction Requests
</h1>
</div>
</div>
<!-- /. ROW -->
<div class="row">
<div class="col-md-12">
<div class="panel panel-default">
<div class="panel-heading">
<ol class="breadcrumb">
<li class="active">
<i class="fa fa-user"></i> List of Transaction Requests
</li>
</ol>
</div>
<div class="panel-body">
<div class="column" >
<tr>
<td>
<table class="table table-hover" border="2">
<col width="5%"></col>
<col width="15%"></col>
<col width="10%"></col>
<col width="10%"></col>
<col width="10%"></col>
<col width="15%"></col>
<col width="15%"></col>
<col width="10%"></col>
<thead>
<tr>
<center>
<th><center>Informant Name</th>
<th><center>Informant Address</th>
<th><center>Informant Contact</th>
<th><center>Informant Email</th>
<th><center>Sighted Person</th>
<th><center>Action</th>
</center>
</tr>
</thead>
<?php
include('mysql_connect.php');
$query="SELECT * from tbl_informant,tbl_missing_person where informant_status='Pending' and reported_id=mp_id";
$result=mysql_query($query);
while($row=mysql_fetch_array($result)){
?>
<tr>
<td><center><?php echo $row['informant_fname'].' '.$row['informant_lname'];?></center></td>
<td><center>
<?php echo $row['informant_address'];?></center></td>
<td><?php echo $row['informant_contact']?></td>
<td><?php echo $row['informant_email']?></td>
<td>
<img src="<?php echo $row['mp_image_location'].$row['mp_image']?>" height=100 width=100><br>
<?php echo $row['mp_fname'].' '.$row['mp_lname']?>
</td>
<td>
<?php
$id=$row['informant_id'];
$_SESSION['id']=$id;
echo "<center>
<button type='button'class='btn btn-primary btn-sm?id=".$id."' data-toggle='modal' title='Confirm'data-target='#ModalConfirm'>
Confirm</button>
<button type='button'class='btn btn-danger btn-sm?id=".$id."' data-toggle='modal' title='Confirm'data-target='#ModalReject'>
Reject</button>
</center>"
?>
</td>
</tr>
<?php
}
?>
<!-- Modal for REJECT-->
<div class="modal fade" id="ModalReject" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">×</button>
<h4 class="modal-title"><b>Rejecting Request:</h4></b>
</div>
<div class="modal-body">
<p>Reason/s: </p>
<textarea cols="75" rows="5" placeholder="Enter reason here.." name="transac_reason"></textarea>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Submit</button>
</div>
</div>
</div>
</div>
<!-- Modal for CONFIRM-->
<div class="modal fade" id="ModalConfirm" role="dialog">
<div class="modal-dialog">
<!-- Modal content-->
<div class="modal-content">
<div class="modal-body">
<p>Are you sure you want to confirm request? </p>
<?php
$modalquery="select * from tbl_informant,tbl_missing_person,tbl_contact_person
where concat(reported_id=mp_id && mp_id=cp_id)";
?>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-primary" >Yes</button>
<button type="button" class="btn btn-default" data-dismiss="modal">No</button>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<!-- /. PAGE INNER -->
</div>
<!-- /. PAGE WRAPPER -->
</div>
<!-- /. WRAPPER -->
<!-- JS Scripts-->
<!-- jQuery Js -->
<script src="assets/js/jquery-1.10.2.js"></script>
<!-- Bootstrap Js -->
<script src="assets/js/bootstrap.min.js"></script>
<!-- Metis Menu Js -->
<script src="assets/js/jquery.metisMenu.js"></script>
<!-- Morris Chart Js -->
<script src="assets/js/morris/raphael-2.1.0.min.js"></script>
<script src="assets/js/morris/morris.js"></script>
<!-- Custom Js -->
<script src="assets/js/custom-scripts.js"></script>
</body>
</html>
You can't execute a live mysql query like this to modify the table.
The best way for this is with ajax, you can catch the id if is on the table and use ajax to execute the mysql query.
I suggest you put the informant id in the value of a button in the table with a class:
<button class="id" data-target="modal" value="<?= $row['informant_id'] ?>"/>
and you can get the value of the button with a jquery event with this:
$(document).on("click", "id", function(){
var id = $(this).val();
console.log(id);
// and handle the value
});
this is one of many ways to pass the variable, if you just want to print it on the modal, create a tag with an id "example" <h1 id="example"></h1> inside the modal and execute this:
$(document).on("click", "id", function(){
var id = $(this).val();
console.log(id);
// and handle the value
$(".modal #example").text(id);
});
Regards.

Session Markup Issue

This top is already created and i have looked at almost all of them but i am still having this issue. The problem i am having is when I try to login to my admin panel everything flows great until i get to the admin dashboard page where it kicks me back to login. I have tried everything and i have one answer. It myself think that for some reason its to saying that i have made a session. My code for login_process.php and dashboard.php are:
login_process.php (Starts the session here. I get no incorrect details error!)
<?php
include '../includes/settings.php';
include '../includes/mysql.php';
$email = $_POST['email'];
$password = $_POST['password'];
$password_hashed = md5($email . $password);
$sql = "SELECT * FROM admins WHERE email='$email' AND password='$password_hashed'";
$result = $conn->query($sql);
if(!$row = $result->fetch_assoc()) {
Header("Location: {$website_domain}/admin/login?s=1");
} else {
session_start();
$_SESSION["id"] = $row['id'];
$_SESSION["loggedIn"] = true;
Header("Location: {$website_domain}/admin/dashboard");
}
?>
dashboard.php (header.php has session_start(); so i don't have to re-add that =)
<?php
if(!isset($_SESSION['loggedIn'])) {
header("Location: {$website_domain}/admin/login");
}
require_once('assets/header.php');
?>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<h1>
Dashboard
<small>Control panel</small>
</h1>
<ol class="breadcrumb">
<li><i class="fa fa-dashboard"></i> Home</li>
<li class="active">Dashboard</li>
</ol>
</section>
<!-- Main content -->
<section class="content">
<!-- Small boxes (Stat box) -->
<div class="row">
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-aqua">
<div class="inner">
<h3>150</h3>
<p>New Orders</p>
</div>
<div class="icon">
<i class="ion ion-bag"></i>
</div>
More info <i class="fa fa-arrow-circle-right"></i>
</div>
</div>
<!-- ./col -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-green">
<div class="inner">
<h3>53<sup style="font-size: 20px">%</sup></h3>
<p>Bounce Rate</p>
</div>
<div class="icon">
<i class="ion ion-stats-bars"></i>
</div>
More info <i class="fa fa-arrow-circle-right"></i>
</div>
</div>
<!-- ./col -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-yellow">
<div class="inner">
<h3>44</h3>
<p>User Registrations</p>
</div>
<div class="icon">
<i class="ion ion-person-add"></i>
</div>
More info <i class="fa fa-arrow-circle-right"></i>
</div>
</div>
<!-- ./col -->
<div class="col-lg-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-red">
<div class="inner">
<h3>65</h3>
<p>Unique Visitors</p>
</div>
<div class="icon">
<i class="ion ion-pie-graph"></i>
</div>
More info <i class="fa fa-arrow-circle-right"></i>
</div>
</div>
<!-- ./col -->
</div>
<!-- /.row -->
<!-- Main row -->
<div class="row">
<!-- Left col -->
<section class="col-lg-7 connectedSortable">
<!-- Custom tabs (Charts with tabs)-->
<div class="nav-tabs-custom">
<!-- Tabs within a box -->
<ul class="nav nav-tabs pull-right">
<li class="active">Area</li>
<li>Donut</li>
<li class="pull-left header"><i class="fa fa-inbox"></i> Sales</li>
</ul>
<div class="tab-content no-padding">
<!-- Morris chart - Sales -->
<div class="chart tab-pane active" id="revenue-chart" style="position: relative; height: 300px;"></div>
<div class="chart tab-pane" id="sales-chart" style="position: relative; height: 300px;"></div>
</div>
</div>
<!-- /.nav-tabs-custom -->
<!-- Chat box -->
<div class="box box-success">
<div class="box-header">
<i class="fa fa-comments-o"></i>
<h3 class="box-title">Chat</h3>
<div class="box-tools pull-right" data-toggle="tooltip" title="Status">
<div class="btn-group" data-toggle="btn-toggle">
<button type="button" class="btn btn-default btn-sm active"><i class="fa fa-square text-green"></i>
</button>
<button type="button" class="btn btn-default btn-sm"><i class="fa fa-square text-red"></i></button>
</div>
</div>
</div>
<div class="box-body chat" id="chat-box">
<!-- chat item -->
<div class="item">
<img src="dist/img/user4-128x128.jpg" alt="user image" class="online">
<p class="message">
<a href="#" class="name">
<small class="text-muted pull-right"><i class="fa fa-clock-o"></i> 2:15</small>
Mike Doe
</a>
I would like to meet you to discuss the latest news about
the arrival of the new theme. They say it is going to be one the
best themes on the market
</p>
<div class="attachment">
<h4>Attachments:</h4>
<p class="filename">
Theme-thumbnail-image.jpg
</p>
<div class="pull-right">
<button type="button" class="btn btn-primary btn-sm btn-flat">Open</button>
</div>
</div>
<!-- /.attachment -->
</div>
<!-- /.item -->
<!-- chat item -->
<div class="item">
<img src="dist/img/user3-128x128.jpg" alt="user image" class="offline">
<p class="message">
<a href="#" class="name">
<small class="text-muted pull-right"><i class="fa fa-clock-o"></i> 5:15</small>
Alexander Pierce
</a>
I would like to meet you to discuss the latest news about
the arrival of the new theme. They say it is going to be one the
best themes on the market
</p>
</div>
<!-- /.item -->
<!-- chat item -->
<div class="item">
<img src="dist/img/user2-160x160.jpg" alt="user image" class="offline">
<p class="message">
<a href="#" class="name">
<small class="text-muted pull-right"><i class="fa fa-clock-o"></i> 5:30</small>
Susan Doe
</a>
I would like to meet you to discuss the latest news about
the arrival of the new theme. They say it is going to be one the
best themes on the market
</p>
</div>
<!-- /.item -->
</div>
<!-- /.chat -->
<div class="box-footer">
<div class="input-group">
<input class="form-control" placeholder="Type message...">
<div class="input-group-btn">
<button type="button" class="btn btn-success"><i class="fa fa-plus"></i></button>
</div>
</div>
</div>
</div>
<!-- /.box (chat box) -->
<!-- TO DO List -->
<div class="box box-primary">
<div class="box-header">
<i class="ion ion-clipboard"></i>
<h3 class="box-title">To Do List</h3>
<div class="box-tools pull-right">
<ul class="pagination pagination-sm inline">
<li>«</li>
<li>1</li>
<li>2</li>
<li>3</li>
<li>»</li>
</ul>
</div>
</div>
<!-- /.box-header -->
<div class="box-body">
<ul class="todo-list">
<li>
<!-- drag handle -->
<span class="handle">
<i class="fa fa-ellipsis-v"></i>
<i class="fa fa-ellipsis-v"></i>
</span>
<!-- checkbox -->
<input type="checkbox" value="">
<!-- todo text -->
<span class="text">Design a nice theme</span>
<!-- Emphasis label -->
<small class="label label-danger"><i class="fa fa-clock-o"></i> 2 mins</small>
<!-- General tools such as edit or delete-->
<div class="tools">
<i class="fa fa-edit"></i>
<i class="fa fa-trash-o"></i>
</div>
</li>
<li>
<span class="handle">
<i class="fa fa-ellipsis-v"></i>
<i class="fa fa-ellipsis-v"></i>
</span>
<input type="checkbox" value="">
<span class="text">Make the theme responsive</span>
<small class="label label-info"><i class="fa fa-clock-o"></i> 4 hours</small>
<div class="tools">
<i class="fa fa-edit"></i>
<i class="fa fa-trash-o"></i>
</div>
</li>
<li>
<span class="handle">
<i class="fa fa-ellipsis-v"></i>
<i class="fa fa-ellipsis-v"></i>
</span>
<input type="checkbox" value="">
<span class="text">Let theme shine like a star</span>
<small class="label label-warning"><i class="fa fa-clock-o"></i> 1 day</small>
<div class="tools">
<i class="fa fa-edit"></i>
<i class="fa fa-trash-o"></i>
</div>
</li>
<li>
<span class="handle">
<i class="fa fa-ellipsis-v"></i>
<i class="fa fa-ellipsis-v"></i>
</span>
<input type="checkbox" value="">
<span class="text">Let theme shine like a star</span>
<small class="label label-success"><i class="fa fa-clock-o"></i> 3 days</small>
<div class="tools">
<i class="fa fa-edit"></i>
<i class="fa fa-trash-o"></i>
</div>
</li>
<li>
<span class="handle">
<i class="fa fa-ellipsis-v"></i>
<i class="fa fa-ellipsis-v"></i>
</span>
<input type="checkbox" value="">
<span class="text">Check your messages and notifications</span>
<small class="label label-primary"><i class="fa fa-clock-o"></i> 1 week</small>
<div class="tools">
<i class="fa fa-edit"></i>
<i class="fa fa-trash-o"></i>
</div>
</li>
<li>
<span class="handle">
<i class="fa fa-ellipsis-v"></i>
<i class="fa fa-ellipsis-v"></i>
</span>
<input type="checkbox" value="">
<span class="text">Let theme shine like a star</span>
<small class="label label-default"><i class="fa fa-clock-o"></i> 1 month</small>
<div class="tools">
<i class="fa fa-edit"></i>
<i class="fa fa-trash-o"></i>
</div>
</li>
</ul>
</div>
<!-- /.box-body -->
<div class="box-footer clearfix no-border">
<button type="button" class="btn btn-default pull-right"><i class="fa fa-plus"></i> Add item</button>
</div>
</div>
<!-- /.box -->
<!-- quick email widget -->
<div class="box box-info">
<div class="box-header">
<i class="fa fa-envelope"></i>
<h3 class="box-title">Quick Email</h3>
<!-- tools box -->
<div class="pull-right box-tools">
<button type="button" class="btn btn-info btn-sm" data-widget="remove" data-toggle="tooltip" title="Remove">
<i class="fa fa-times"></i></button>
</div>
<!-- /. tools -->
</div>
<div class="box-body">
<form action="#" method="post">
<div class="form-group">
<input type="email" class="form-control" name="emailto" placeholder="Email to:">
</div>
<div class="form-group">
<input type="text" class="form-control" name="subject" placeholder="Subject">
</div>
<div>
<textarea class="textarea" placeholder="Message" style="width: 100%; height: 125px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"></textarea>
</div>
</form>
</div>
<div class="box-footer clearfix">
<button type="button" class="pull-right btn btn-default" id="sendEmail">Send
<i class="fa fa-arrow-circle-right"></i></button>
</div>
</div>
</section>
<!-- /.Left col -->
<!-- right col (We are only adding the ID to make the widgets sortable)-->
<section class="col-lg-5 connectedSortable">
<!-- Map box -->
<div class="box box-solid bg-light-blue-gradient">
<div class="box-header">
<!-- tools box -->
<div class="pull-right box-tools">
<button type="button" class="btn btn-primary btn-sm daterange pull-right" data-toggle="tooltip" title="Date range">
<i class="fa fa-calendar"></i></button>
<button type="button" class="btn btn-primary btn-sm pull-right" data-widget="collapse" data-toggle="tooltip" title="Collapse" style="margin-right: 5px;">
<i class="fa fa-minus"></i></button>
</div>
<!-- /. tools -->
<i class="fa fa-map-marker"></i>
<h3 class="box-title">
Visitors
</h3>
</div>
<div class="box-body">
<div id="world-map" style="height: 250px; width: 100%;"></div>
</div>
<!-- /.box-body-->
<div class="box-footer no-border">
<div class="row">
<div class="col-xs-4 text-center" style="border-right: 1px solid #f4f4f4">
<div id="sparkline-1"></div>
<div class="knob-label">Visitors</div>
</div>
<!-- ./col -->
<div class="col-xs-4 text-center" style="border-right: 1px solid #f4f4f4">
<div id="sparkline-2"></div>
<div class="knob-label">Online</div>
</div>
<!-- ./col -->
<div class="col-xs-4 text-center">
<div id="sparkline-3"></div>
<div class="knob-label">Exists</div>
</div>
<!-- ./col -->
</div>
<!-- /.row -->
</div>
</div>
<!-- /.box -->
<!-- solid sales graph -->
<div class="box box-solid bg-teal-gradient">
<div class="box-header">
<i class="fa fa-th"></i>
<h3 class="box-title">Sales Graph</h3>
<div class="box-tools pull-right">
<button type="button" class="btn bg-teal btn-sm" data-widget="collapse"><i class="fa fa-minus"></i>
</button>
<button type="button" class="btn bg-teal btn-sm" data-widget="remove"><i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="box-body border-radius-none">
<div class="chart" id="line-chart" style="height: 250px;"></div>
</div>
<!-- /.box-body -->
<div class="box-footer no-border">
<div class="row">
<div class="col-xs-4 text-center" style="border-right: 1px solid #f4f4f4">
<input type="text" class="knob" data-readonly="true" value="20" data-width="60" data-height="60" data-fgColor="#39CCCC">
<div class="knob-label">Mail-Orders</div>
</div>
<!-- ./col -->
<div class="col-xs-4 text-center" style="border-right: 1px solid #f4f4f4">
<input type="text" class="knob" data-readonly="true" value="50" data-width="60" data-height="60" data-fgColor="#39CCCC">
<div class="knob-label">Online</div>
</div>
<!-- ./col -->
<div class="col-xs-4 text-center">
<input type="text" class="knob" data-readonly="true" value="30" data-width="60" data-height="60" data-fgColor="#39CCCC">
<div class="knob-label">In-Store</div>
</div>
<!-- ./col -->
</div>
<!-- /.row -->
</div>
<!-- /.box-footer -->
</div>
<!-- /.box -->
<!-- Calendar -->
<div class="box box-solid bg-green-gradient">
<div class="box-header">
<i class="fa fa-calendar"></i>
<h3 class="box-title">Calendar</h3>
<!-- tools box -->
<div class="pull-right box-tools">
<!-- button with a dropdown -->
<div class="btn-group">
<button type="button" class="btn btn-success btn-sm dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-bars"></i></button>
<ul class="dropdown-menu pull-right" role="menu">
<li>Add new event</li>
<li>Clear events</li>
<li class="divider"></li>
<li>View calendar</li>
</ul>
</div>
<button type="button" class="btn btn-success btn-sm" data-widget="collapse"><i class="fa fa-minus"></i>
</button>
<button type="button" class="btn btn-success btn-sm" data-widget="remove"><i class="fa fa-times"></i>
</button>
</div>
<!-- /. tools -->
</div>
<!-- /.box-header -->
<div class="box-body no-padding">
<!--The calendar -->
<div id="calendar" style="width: 100%"></div>
</div>
<!-- /.box-body -->
<div class="box-footer text-black">
<div class="row">
<div class="col-sm-6">
<!-- Progress bars -->
<div class="clearfix">
<span class="pull-left">Task #1</span>
<small class="pull-right">90%</small>
</div>
<div class="progress xs">
<div class="progress-bar progress-bar-green" style="width: 90%;"></div>
</div>
<div class="clearfix">
<span class="pull-left">Task #2</span>
<small class="pull-right">70%</small>
</div>
<div class="progress xs">
<div class="progress-bar progress-bar-green" style="width: 70%;"></div>
</div>
</div>
<!-- /.col -->
<div class="col-sm-6">
<div class="clearfix">
<span class="pull-left">Task #3</span>
<small class="pull-right">60%</small>
</div>
<div class="progress xs">
<div class="progress-bar progress-bar-green" style="width: 60%;"></div>
</div>
<div class="clearfix">
<span class="pull-left">Task #4</span>
<small class="pull-right">40%</small>
</div>
<div class="progress xs">
<div class="progress-bar progress-bar-green" style="width: 40%;"></div>
</div>
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</div>
</div>
<!-- /.box -->
</section>
<!-- right col -->
</div>
<!-- /.row (main row) -->
</section>
<!-- /.content -->
</div>
<!-- /.content-wrapper -->
<?php
require_once('assets/footer.php');
?>
I would appreciate all help to this issue. Hopefully this does not get deleted because i have searched the whole site trying diff things but nothing on here helped so i thought i would post. Once again, i appreciate all help!
session_start(); must be on the top:
<?php
session_start();
You move require_once('assets/header.php'); up and take care that session_start(); is on the top.
For more details look at Where exactly do I put a SESSION_START?

PDO insert query won't work

My PDO query won't work. This is my page:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Rally is our passion">
<meta name="author" content="Robin Rosiers">
<title>Sponsors - RPR Admin</title>
<?php require_once ('include/core.php'); ?>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.css" rel="stylesheet">
<link rel="shortcut icon" href="./img/favicon.ico">
<!-- Add custom CSS here -->
<link href="css/sb-admin.css" rel="stylesheet">
<link rel="stylesheet" href="font-awesome/css/font-awesome.min.css">
<!-- Page Specific CSS -->
<link rel="stylesheet" href="http://cdn.oesmith.co.uk/morris-0.4.3.min.css">
</head>
<body>
<div id="wrapper">
<!-- Sidebar -->
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-ex1-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="index.php" alt="Rallypodium & Reporting" title="Rallypodium & Reporting">RPR - Administration Panel</a>
</div>
<!-- Collect the nav links, forms, and other content for toggling -->
<div class="collapse navbar-collapse navbar-ex1-collapse">
<ul class="nav navbar-nav side-nav">
<li><i class="fa fa-home"></i> Home</li>
<li><i class="fa fa-list-alt"></i> Nieuws</li>
<li><i class="fa fa-camera"></i> Foto's</li>
<li><i class="fa fa-edit"></i> Pagina's</li>
<li><i class="fa fa-font"></i> Bewerk pagina's</li>
<li><i class="fa fa-desktop"></i> Melding(en)</li>
<li class="active"><i class="fa fa-money"></i> Sponsors</li>
<li><i class="fa fa-wrench"></i> Instellingen</li>
<li><i class="fa fa-pencil"></i> Account instellingen</li>
<li><i class="fa fa-check"></i> Administrator toevoegen</li>
</ul>
<ul class="nav navbar-nav navbar-right navbar-user">
<li class="dropdown user-dropdown">
<i class="fa fa-user"></i> {Gebruikersnaam} <b class="caret"></b>
<ul class="dropdown-menu">
<li><i class="fa fa-gear"></i> Instellingen</li>
<li class="divider"></li>
<li><i class="fa fa-power-off"></i> Log uit</li>
</ul>
</li>
</li>
</ul>
</div><!-- /.navbar-collapse -->
</nav>
<div id="page-wrapper">
<div class="row">
<div class="col-lg-12">
<h1>Sponsors<small><br></small></h1>
<ol class="breadcrumb">
<li class="active"><i class="fa fa-money"></i> Sponsors</li>
</ol>
</div>
</div><!-- /.row -->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-plus"></i> Sponsor toevoegen</h3>
</div>
<div class="panel-body" style="max-height:600px; overflow:auto">
<!-- Content/script hier om een sponsor te adden. -->
<?php
if($_SERVER['REQUEST_METHOD']=="POST") {
$naam = $db->quote($_POST['naam']);
$site = $db->quote($_POST['site']);
$img = $db->quote($_POST['img']);
$opbrengst = $db->quote($_POST['opbrengst']);
$duur = $db->quote($_POST['duur']);
$sql = " INSERT INTO sponsors (naam, site, img, opbrengst, duur) VALUES ('".$naam.", ".$site.", ".$img.", ".$opbrengst.", ".$duur."')";
}
?>
<center>
<form action="?ok" method="post">
Sponsor naam: <input name="naam" class="form-control" type="text" placeholder="Naam..." style="width:auto;"><br>
Site (url) <input name="site" class="form-control" type="text" placeholder="http://" style="width:auto;"><br>
Sponsor image (url) <input name="img" class="form-control" type="text" placeholder="vb http://i.imgur.com/" style="width:auto;"><br>
Opbrengst: € <input name="opbrengst" class="form-control" type="text" placeholder="opbrengst" style="width:auto;"> /maand<br>
<div class="form-group">
<label>Duur:</label>
<select name="duur" class="form-control" style="width:auto;">
<option>1 maand</option>
<option>2 maanden</option>
<option>3 maanden</option>
<option>4 maanden</option>
<option>5 maanden</option>
<option>6 maanden</option>
<option>7 maanden</option>
<option>8 maanden</option>
<option>9 maanden</option>
<option>10 maanden</option>
<option>11 maanden</option>
<option>1 jaar</option>
</select>
</div>
<button type="submit" class="btn">Opslaan</button>
</form>
</center>
</div>
</div>
</div>
</div><!-- /.row -->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-primary">
<div class="panel-heading">
<h3 class="panel-title"><i class="fa fa-list"></i> Sponsor lijst</h3>
</div>
<div class="panel-body">
<?php
$sql = "SELECT * FROM sponsors ORDER BY id";
$results = $db->query($sql);
foreach($results as $row)
{
echo '<div class="alert alert-info">';
echo '<button type="button" class="close" data-dismiss="alert" aria-hidden="true" alt="verwijder de sponsor." title="verwijder de sponsor.">×</button>';
echo '<p>Naam: ';
echo $row['naam'];
echo ' <i class="fa fa-tag"></i> </p>';
echo '<p>Opbrengst: ';
echo $row['opbrengst'];
echo ' <i class="fa fa-money"></i> </p>';
echo '</div>';
}
?>
</div>
</div>
</div>
</div>
</div><!-- /.row -->
</div><!-- /#page-wrapper -->
</div><!-- /#wrapper -->
<!-- JavaScript -->
<script src="js/jquery-1.10.2.js"></script>
<script src="js/bootstrap.js"></script>
<!-- Page Specific Plugins -->
<script src="//cdnjs.cloudflare.com/ajax/libs/raphael/2.1.0/raphael-min.js"></script>
<script src="http://cdn.oesmith.co.uk/morris-0.4.3.min.js"></script>
<script src="js/morris/chart-data-morris.js"></script>
<script src="js/tablesorter/jquery.tablesorter.js"></script>
<script src="js/tablesorter/tables.js"></script>
</body>
</html>
It is very wired. The select code works fine, but the insert query doesn't. What's wrong with it?
You assigned the INSERT query string to a var, but didn't execute $db->query($sql); on it.
After
$sql = " INSERT INTO sponsors (naam, site, img, opbrengst, duur) VALUES ('".$naam.", ".$site.", ".$img.", ".$opbrengst.", ".$duur."')";
add
$db->query($sql);
you need tell PDO to rise error
setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
after that you can easily catch your problem .i wish

Categories