I want to show notifications like facebook has but way more simple just to inform but I'm having some problems.
This is the bug in all users they have all the same notifications even if i create a new account.
Code:
<?php
include("session.php");
?>
<html>
<head>
<link rel="icon" href="../imagens/4.png" />
<title>BlendUp</title>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="../css/costum.css">
<link rel="icon" href="Icone.png" width="50px" height="45px">
<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>
<body>
<div id="navbar" class="navbar navbar-fixed-top">
<div class="navbar-def">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<img src="../imagens/5.png" width="125px" height="35px" >
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav">
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Pedidos
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Criar</li>
<li>Visualizar</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Conteúdo
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Criar</li>
<li>Visualizar</li>
</ul>
</li>
<li class="dropdown">
<a class="dropdown-toggle" data-toggle="dropdown" href="#">Portais
<span class="caret"></span></a>
<ul class="dropdown-menu">
<li>Criar</li>
<li>Visualizar</li>
</ul>
</li>
</ul>
<?php
$result = mysqli_query($link,"SELECT * from pedidos where p_nomeuti='{$_SESSION['login_username']}' and p_estado='0'");
$result1 = mysqli_query($link,"SELECT count(*) from pedidos where p_autor='$login_session'");
$num_rows = mysqli_num_rows($result);
$num_rows1 = mysqli_num_rows($result1);
$numrowstotal= $num_rows + $num_rows1;
echo $num_rows;
echo $num_rows1;
echo $numrowstotal;
?>
<ul class="nav navbar-nav navbar-right">
<li><a class="dropdown-toggle" data-toggle="dropdown">Bem Vindo, <?php echo $login_session;?><?php echo $numrowstotal;?> </a>
<ul class="dropdown-menu">
<li><a>Por terminar <?php echo $num_rows;?></a></li>
<li><a>A fazer <?php echo $num_rows1;?></a></li>
</ul>
<li> Logout <img src="../imagens/6.png" style="width:15px; height:15px" align="middle" > </li>
</ul>
</div>
</div><!--/.nav-collapse -->
<body style="background-color:#122a82">
</div>
<div class="container">
</head>
</html>
<link rel="stylesheet" type="text/css" href="../css/pesquisa.css">
<div class="well-searchbox">
<form class="form-horizontal" role="form">
<div class="form-group">
<label class="col-md-4 control-label">Keyword</label>
<div class="col-md-8">
<input type="text" class="form-control" placeholder="Keyword">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Portais</label>
<div class="col-md-8">
<select class="form-control" placeholder="Country">
<option value="">All</option>
<option value="">Country 1</option>
<option value="">Country 2</option>
</select>
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Data Inicio</label>
<div class="col-md-8">
<input class="form-control" type="date" name="dataini">
</div>
</div>
<div class="form-group">
<label class="col-md-4 control-label">Data Fim</label>
<div class="col-md-8">
<input class="form-control" type="date" name="datafim">
</div>
</div>
<div class="form-group">
<div class="col-sm-offset-4 col-sm-5">
<button type="submit" class="btn btn-primary">Pesquisa</button>
</div>
</form>
</div>
</body>
</html>
Session.php
<?php
include('../config/db.php');
session_start();
$check=$_SESSION['login_username'];
$session=mysqli_query($link,"select u_nick from utilizadores where u_nick='$check' ");
$row=mysqli_fetch_array($session);
$login_session=$row['u_nick'];
if(!isset($login_session))
{
header("Location:../index.html");
}
?>
I'm with php like I've said in the others questions.
This is not full code this is a part of my menu.
If you need more of my code tell me please ill post it here
you are using count function in query which return count of the number of rows retrieved by a SELECT statement so mysqli_num_rows() return always one .
SELECT * from pedidos where p_nomeuti='{$_SESSION['login_username']}' and p_estado='0'
SELECT * from pedidos where p_autor='{$_SESSION['login_username']}'
so now use mysqli_num_rows.
Related
https://imgur.com/a/PYokL
Hello,I am aware that there are some duplicate column in my database at the moment as I encountered some errors I'm just trying to make my website functional at the moment. I am currently working on displaying the highest bid for a listing.I am confused as to how I would find the highest bid for each specific listing as the bids all seem to bundle together into one table.I was wondering if anyone could help me do this?
<?php
require 'config.php';
if(isset($_POST['submit']))
{
$valueToSearch = $_POST['valueToSearch'];
// search in all table columns
// using concat mysql function
$query = "SELECT * FROM listings` WHERE CONCAT(`location`, `description`, `price`, `date`,`title`) LIKE '%".$valueToSearch."%'";
$query2 = "SELECT `listID` FROM listings"
$search_result = filterTable($query);
}
else {
$query = "SELECT * FROM `listings`";
$search_result = filterTable($query);
}
// function to connect and execute the query
function filterTable($query)
{
$conn = mysqli_connect("localhost", "root", "", "auction");
$filter_Result = mysqli_query($conn, $query);
return $filter_Result;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bid4MyJob</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Bid4MyJob">
<meta name="author" content="James Wood">
<!-- CSS -->
<link href="assets/css/bootstrap.css" rel="stylesheet" type="text/css">
<link href="assets/css/font-awesome.min.css" rel="stylesheet" type="text/css">
<link href="assets/css/main.css" rel="stylesheet" type="text/css">
<link href="assets/css/my-custom-styles.css" rel="stylesheet" type="text/css">
<!-- IE 9 Fallback-->
<!--[if IE 9]>
<link href="assets/css/ie.css" rel="stylesheet">
<![endif]-->
<!-- GOOGLE FONTS -->
<link href='http://fonts.googleapis.com/css?family=Open+Sans:300,400italic,400,600,700' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Roboto+Condensed:300,300italic,400italic,700,400,300' rel='stylesheet' type='text/css'>
<!-- FAVICONS -->
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="assets/ico/repute144x144.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="assets/ico/repute114x114.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="assets/ico/repute72x72.png">
<link rel="apple-touch-icon-precomposed" href="assets/ico/repute57x57.png">
<link rel="shortcut icon" href="assets/ico/favicon.png">
</head>
<body>
<!-- WRAPPER -->
<div class="wrapper">
<!-- NAVBAR -->
<nav class="navbar navbar-default " role="navigation">
<div class="container">
<!-- TOPBAR -->
<div class="topbar">
<ul class="list-inline top-nav">
<li>
<div class="btn-group">
<button type="button" class="btn btn-link dropdown-toggle btn-xs" data-toggle="dropdown"><img src="assets/img/flags/United-Kingdom.png" alt="United Kingdom"> United Kingdom <span class="caret"></span></button>
<ul class="dropdown-menu dropdown-menu-right country-selector" role="menu">
<li>
<img src="assets/img/flags/United-Kingdom.png" alt="United Kingdom"> United Kingdom
</li>
<li>
<img src="assets/img/flags/Japan.png" alt="Japan"> Japan
</li>
<li>
<img src="assets/img/flags/China.png" alt="China"> China
</li>
<li>
<img src="assets/img/flags/Germany.png" alt="Germany"> Germany
</li>
</ul>
</div>
</li>
<li>Help</li>
<li>Support</li>
</ul>
<div class="searchbox">
<form method="post">
<div class="input-group input-group-sm">
<input type="text" class="form-control" placeholder="search ...">
<span class="input-group-btn">
<button class="btn btn-default" type="button"><i class="fa fa-search"></i></button>
</span>
</div>
</form>
</div>
</div>
<!-- END TOPBAR -->
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#main-nav">
<span class="sr-only">Toggle Navigation</span>
<i class="fa fa-bars"></i>
</button>
<a href="index.html" class="navbar-brand navbar-logo navbar-logo-bigger">
</a>
</div>
<!-- MAIN NAVIGATION -->
<div id="main-nav" class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li>
HOME
</li>
<li>
HOW IT WORKS
</li>
<li>
POST JOB
</li>
<li>
FIND JOB
</li>
<li>
SIGN UP
</li>
<li>
LOGIN
</li>
</ul>
</div>
<!-- END MAIN NAVIGATION -->
</div>
</nav>
<!-- END NAVBAR -->
<!-- BREADCRUMBS -->
<div class="page-header">
<div class="container">
<h1 class="page-title pull-left">Find Job</h1>
<ol class="breadcrumb">
<li>Home</li>
<li class="active">Find Job</li>
</ol>
</div>
</div>
<!-- END BREADCRUMBS -->
<!-- PAGE CONTENT -->
<div class="page-content page-search-result">
<div class="container">
<!-- Search Form -->
<form class="form form-horizontal" action="findjob.php" method="post">
<div class="input-group input-group-lg">
<div class="input-group-btn">
<!--<select id="search-type-select" name="valueToSearch" class="multiselect multiselect-single-lg search-type-select">
<option value="all" selected="selected">All</option>
<option value="page">Page</option>
<option value="task">Task</option>
<option value="user">User</option>
<option value="image">Image</option>
</select>
</div>-->
<input class="form-control input-lg" type="text" name="valueToSearch" placeholder="type keyword ..." />
<span class="input-group-btn">
<button type="submit" name= "submit" value="Search" class="btn btn-primary btn-lg"><i class="icon ion-android-search"></i> Go</button>
</span>
</div>
</form>
<!-- End Search Form -->
</div>
</div>
<div>
<table>
<tr>
<th>Title</th>
<th>Location</th>
<th>Description</th>
<th>Budget</th>
<th>Due date</th>
</tr>
<!-- populate table from mysql database -->
<?php while($row = mysqli_fetch_array($search_result)):?>
<tr>
<td><?php echo $row['title'];?></td>
<td><?php echo $row['location'];?></td>
<td><?php echo $row['description'];?></td>
<td><?php echo $row['price'];?></td>
<td><?php echo $row['date'];?></td>
<td><form method="post" action="actionpage5.php" class="form-horizontal">
<?php //echo _("Enter ") . ' ' . $last_bid_plus . ' ' . _('or more'); ?>
<div class="input-group ">
<input type="number" value="bid" class="form-control" name="bid" id= "bid" required/>
</div>
<br/>
<input type="submit" name="sb_bid" value="<?php echo _('Place your Bid'); ?>"
class="btn btn-xlarge btn-block btn-primary"/>
<br/>
</form></td>
</tr>
<?php endwhile;?>
</table>
</div>
<!-- END PAGE CONTENT -->
<!-- FOOTER -->
<footer>
<div class="container">
<div class="row">
<div class="col-md-4">
<!-- COLUMN 1 -->
<h3 class="sr-only">ABOUT US</h3>
<img src="assets/img/logo/repute-logo-light.png" class="logo" alt="Repute">
<p>Proactively aggregate B2B initiatives before extensive channels. Monotonectally extend interactive methods of empowerment through excellent applications. Rapidiously synergize visionary products with sticky technology.</p>
<br>
<address class="margin-bottom-30px">
<ul class="list-unstyled">
<li>Unit 5, Block B Nesfield Road
<br/> Colchester, Essex CO4 3ZL 222222</li>
<li>Phone: 01206 588 000</li>
<li>Email: sales#universalwebdesign.co.uk</li>
</ul>
</address>
<!-- END COLUMN 1 -->
</div>
<div class="col-md-4">
<!-- COLUMN 2 -->
<h3 class="footer-heading">USEFUL LINKS</h3>
<div class="row margin-bottom-30px">
<div class="col-xs-6">
<ul class="list-unstyled footer-nav">
<li>About Us</li>
<li>News</li>
<li>Community</li>
<li>Career</li>
<li>Blog</li>
</ul>
</div>
<div class="col-xs-6">
<ul class="list-unstyled footer-nav">
<li>Press Kit</li>
<li>FAQ</li>
<li>Terms</li>
<li>Privacy Policy</li>
<li>Contact Us</li>
</ul>
</div>
</div>
<!-- END COLUMN 2 -->
</div>
<div class="col-md-4">
<!-- COLUMN 3 -->
<div class="newsletter">
<h3 class="footer-heading">NEWSLETTER</h3>
<p>Get the latest update from us by subscribing to our newsletter.</p>
<form class="newsletter-form" method="POST">
<div class="input-group input-group-lg">
<input type="email" class="form-control" name="email" placeholder="youremail#domain.com">
<span class="input-group-btn"><button class="btn btn-primary" type="button"><i class="fa fa-spinner fa-spin"></i><span>SUBSCRIBE</span></button>
</span>
</div>
<div class="alert"></div>
</form>
</div>
<div class="social-connect">
<h3 class="footer-heading">GET CONNECTED</h3>
<ul class="list-inline social-icons">
<li><i class="fa fa-facebook"></i></li>
<li><i class="fa fa-twitter"></i></li>
<li><i class="fa fa-google-plus"></i></li>
<li><i class="fa fa-rss"></i></li>
</ul>
</div>
<!-- END COLUMN 3 -->
</div>
</div>
</div>
<!-- COPYRIGHT -->
<div class="text-center copyright">
©2018 Bid4MyJob. All Rights Reserved.
</div>
<!-- END COPYRIGHT -->
</footer>
<!-- END FOOTER -->
</div>
<!-- END WRAPPER -->
<!-- JAVASCRIPTS -->
<script src="assets/js/jquery-2.1.1.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/plugins/bootstrap-multiselect/bootstrap-multiselect.js"></script>
<script src="assets/js/plugins/autohidingnavbar/jquery.bootstrap-autohidingnavbar.min.js"></script>
<script src="assets/js/repute-scripts.js"></script>
</body>
</html>
$query = "SELECT MAX(bid) FROM listingsWHERE CONCAT(location,description,price,date,title`) LIKE '%".$valueToSearch."%' GROUP BY listing"
This question already has answers here:
Reference - What does this error mean in PHP?
(38 answers)
Closed 5 years ago.
I'm a beginner when it comes to PHP and I've been trying the whole day to fix this error. I'm trying to make a profile page here where the user will enter his username and that username will be saved in the MySQL database then I want the username to print on the username blank which he/she used to fill in the first place. Now when I enter the username, the username gets inserted in the database. But it doesn't get echo'd/printed on the blank like I want it to.
user.php:
<?php
ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
/* Displays user information and some useful messages */
session_start();
include 'db.php';
// Check if user is logged in using the session variable
if ( $_SESSION['logged_in'] != 1 ) {
$_SESSION['message'] = "You must log in before viewing your profile page!";
header("location: error.php");
}
else {
// Makes it easier to read
$first_name = $_SESSION['first_name'];
$last_name = $_SESSION['last_name'];
$email = $_SESSION['email'];
$active = $_SESSION['active'];
$username = $_SESSION['username'];
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/png" href="assets/img/favicon.ico">
<title>Social Junction | User Profile</title>
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
<meta name="viewport" content="width=device-width" />
<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet" />
<!-- Animation library for notifications -->
<link href="assets/css/animate.min.css" rel="stylesheet"/>
<!-- Light Bootstrap Table core CSS -->
<link href="assets/css/light-bootstrap-dashboard.css" rel="stylesheet"/>
<!-- CSS for Demo Purpose, don't include it in your project -->
<link href="assets/css/demo.css" rel="stylesheet" />
<!-- Fonts and icons -->
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<link href='//fonts.googleapis.com/css?family=Roboto:400,700,300' rel='stylesheet' type='text/css'>
<link href="assets/css/pe-icon-7-stroke.css" rel="stylesheet" />
</head>
<body>
<div class="wrapper">
<div class="sidebar" data-color="blue" data-image="http://www.zastavki.com/pictures/originals/2015/Creative_Wallpaper_Set_of_business_people_100390_.jpg">
<!-- you can change the color of the sidebar using: data-color="blue | azure | green | orange | red | purple" -->
<div class="sidebar-wrapper">
<div class="pic"></div>
<div class="logo">
<a href="#">
<span style="font-size: 28px;">Hello <span style="font-weight: bold;"><?php echo $first_name.' '.$last_name; ?>!</span></span>
</a>
</div>
<ul class="nav">
<li>
<a href="dashboard.php">
<i class="pe-7s-graph"></i>
<p>Dashboard</p>
</a>
</li>
<li class="active">
<a href="user.html">
<i class="pe-7s-user"></i>
<p>User Profile</p>
</a>
</li>
</ul>
</div>
</div>
<div class="main-panel">
<nav class="navbar navbar-default navbar-fixed">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigation-example-2">
<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="#">Profile</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-left">
<li>
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-dashboard"></i>
</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-globe"></i>
<b class="caret"></b>
<span class="notification">5</span>
</a>
<ul class="dropdown-menu">
<li>Notification 1</li>
<li>Notification 2</li>
<li>Notification 3</li>
<li>Notification 4</li>
<li>Another notification</li>
</ul>
</li>
<li>
<a href="">
<i class="fa fa-search"></i>
</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="">
Account
</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Dropdown
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something</li>
<li>Another action</li>
<li>Something</li>
<li class="divider"></li>
<li>Separated link</li>
</ul>
</li>
<li>
<a href="#">
Log out
</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-8">
<div class="card">
<div class="header">
<h4 class="title">Edit Profile</h4>
</div>
<div class="content">
<form method="POST" action="action.php">
<div class="row">
<div class="col-md-5">
<div class="form-group">
<label>Company (disabled)</label>
<input type="text" class="form-control" disabled placeholder="Company" value="Creative Code Inc.">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>Username</label>
<input name="username" type="text" class="form-control" placeholder="Username" value="<?php echo $username; ?>">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" placeholder="Email" value="<?php echo $email; ?>">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>First Name</label>
<input type="text" name="first_name" class="form-control" placeholder="Company" value="<?php echo $first_name; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Last Name</label>
<input type="text" name="last_name" class="form-control" placeholder="Last Name" value="<?php echo $last_name; ?>">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Address</label>
<input type="text" name="address" class="form-control" placeholder="Home Address" value="Bld Mihail Kogalniceanu, nr. 8 Bl 1, Sc 1, Ap 09">
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>City</label>
<input type="text" name="city" class="form-control" placeholder="City" value="Mike">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Country</label>
<input type="text" name="country" class="form-control" placeholder="Country" value="Andrew">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Postal Code</label>
<input type="number" class="form-control" placeholder="ZIP Code">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>About Me</label>
<textarea name="aboutme" rows="5" class="form-control" placeholder="Here can be your description" value="Mike">Lamborghini Mercy, Your chick she so thirsty, I'm in that two seat Lambo.</textarea>
</div>
</div>
</div>
<button type="submit" class="btn btn-info btn-fill pull-right">Update Profile</button>
<div class="clearfix"></div>
</form>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card card-user">
<div class="image">
<img src="https://ununsplash.imgix.net/photo-1431578500526-4d9613015464?fit=crop&fm=jpg&h=300&q=75&w=400" alt="..."/>
</div>
<div class="content">
<div class="author">
<a href="#">
<img class="avatar border-gray" src="assets/img/faces/face-3.jpg" alt="..."/>
<h4 class="title"><?php echo $first_name; ?><br />
<small><?php echo $last_name; ?></small>
</h4>
</a>
</div>
<p class="description text-center"> "Lamborghini Mercy <br>
Your chick she so thirsty <br>
I'm in that two seat Lambo"
</p>
</div>
<hr>
<div class="text-center">
<button href="#" class="btn btn-simple"><i class="fa fa-facebook-square"></i></button>
<button href="#" class="btn btn-simple"><i class="fa fa-twitter"></i></button>
<button href="#" class="btn btn-simple"><i class="fa fa-google-plus-square"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container-fluid">
<nav class="pull-left">
<ul>
<li>
<a href="#">
Home
</a>
</li>
<li>
<a href="#">
Company
</a>
</li>
<li>
<a href="#">
Portfolio
</a>
</li>
<li>
<a href="#">
Blog
</a>
</li>
</ul>
</nav>
<p class="copyright pull-right">
© 2016 Creative Tim, made with love for a better web
</p>
</div>
</footer>
</div>
</div>
</body>
<!-- Core JS Files -->
<script src="assets/js/jquery-1.10.2.js" type="text/javascript"></script>
<script src="assets/js/bootstrap.min.js" type="text/javascript"></script>
<!-- Checkbox, Radio & Switch Plugins -->
<script src="assets/js/bootstrap-checkbox-radio-switch.js"></script>
<!-- Charts Plugin -->
<script src="assets/js/chartist.min.js"></script>
<!-- Notifications Plugin -->
<script src="assets/js/bootstrap-notify.js"></script>
<!-- Google Maps Plugin -->
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<!-- Light Bootstrap Table Core javascript and methods for Demo purpose -->
<script src="assets/js/light-bootstrap-dashboard.js"></script>
<!-- Light Bootstrap Table DEMO methods, don't include it in your project! -->
<script src="assets/js/demo.js"></script>
</html>
TL;DR: This is the main line where I'm trying to echo $username:
<div class="col-md-3">
<div class="form-group">
<label>Username</label>
<input name="username" type="text" class="form-control" placeholder="Username" value="<?php echo $username; ?>">
</div>
</div>
And this is the form's action.php:
<?php
ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$con = mysqli_connect('localhost', 'id1753243_venom', 'roushan123', 'id1753243_gameware_01');
if(!$con)
{
echo 'Not connected to the server';
}
if(isset($_POST['username'])){ $username = $_POST['username'];
$sql = "UPDATE users SET username='".mysqli_real_escape_string($con,$username)."' WHERE id = 1";
$insert = mysqli_query($con,$sql);
}
if(!$insert)
{
echo 'Not inserted';
}
else
{
echo 'Inserted';
}
header("refresh:2; url=user.php");
?>
Username gets successfully inserted in MySQL database BUT I can't get it to print on the form blank. Why is that?
NOTE: I did not code the login system. It already had variables defined e.g email, fname, lname so it was easy for me to echo them on the blanks. I have been searching for help for 2 days. Can't fix it yet. I'm hoping someone here can help me.
Change your action.php with below code
<?php
session_start(); //---> start session
ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$con = mysqli_connect('localhost', 'id1753243_venom', 'roushan123', 'id1753243_gameware_01');
if(!$con)
{
echo 'Not connected to the server';
}
if(isset($_POST['username']))
{
$username = $_POST['username'];
$sql = "UPDATE users SET username='".mysqli_real_escape_string($con,$username)."' WHERE id = 1";
$insert = mysqli_query($con,$sql);
$_SESSION['username'] = $username; //---> this will store username into session variable
}
if(!$insert)
{
echo 'Not inserted';
}
else
{
echo 'Inserted';
}
header("refresh:2; url=user.php");
?>
If you need more guidelines on this let me know... I'm happy to help you with.
I'm trying to create a profile page with blanks like username, city etc. I have successfully stored username & city in the MySQL Database using the UPDATE query. I have set the WHERE condition according to the email of the users. I have made 2 accounts with separates emails, for testing purposes. When I logged in from account #1, entered username & id, it was successfully stored in the correct row. Then I logged out, and logged in from account #2, and the username & city I entered in account #1 was duplicated and printed on blanks of account #2. BUT in database, the data was still distinguished until I pressed ENTER. So my question is, why is this happening and how do I fix this?
Action.php:
<?php
session_start(); //---> start session
ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
$con = mysqli_connect('localhost', 'id1753243_venom', 'roushan123', 'id1753243_gameware_01');
if(!$con)
{
echo 'Not connected to the server';
}
$city = $_SESSION['city'];
$city = $_POST['city'];
if(isset($_POST['username']))
if(isset($_POST['city']))
{
$username = $_POST['username'];
$sql = "UPDATE users SET username='".mysqli_real_escape_string($con,$username)."', city = '$city' WHERE email='".mysqli_real_escape_string($con,$_SESSION['email'])."'";
$insert = mysqli_query($con,$sql);
$_SESSION['username'] = $username; //---> this will store username into session variable
$_SESSION['city'] = $city; //---> this will store city into session variable
}
if(!$insert)
{
echo 'Not inserted';
}
else
{
echo 'Inserted';
}
header("refresh:2; url=user.php");
?>
And this is the user.php:
<?php
ini_set('display_errors', 1); ini_set('log_errors',1); error_reporting(E_ALL); mysqli_report(MYSQLI_REPORT_ERROR | MYSQLI_REPORT_STRICT);
/* Displays user information and some useful messages */
session_start();
include 'db.php';
// Check if user is logged in using the session variable
if ( $_SESSION['logged_in'] != 1 ) {
$_SESSION['message'] = "You must log in before viewing your profile page!";
header("location: error.php");
}
else {
// Makes it easier to read
$first_name = $_SESSION['first_name'];
$last_name = $_SESSION['last_name'];
$email = $_SESSION['email'];
$active = $_SESSION['active'];
$username = $_SESSION['username'];
$city = $_SESSION['city'];
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" type="image/png" href="assets/img/favicon.ico">
<title>Social Junction | User Profile</title>
<meta content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0' name='viewport' />
<meta name="viewport" content="width=device-width" />
<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.min.css" rel="stylesheet" />
<!-- Animation library for notifications -->
<link href="assets/css/animate.min.css" rel="stylesheet"/>
<!-- Light Bootstrap Table core CSS -->
<link href="assets/css/light-bootstrap-dashboard.css" rel="stylesheet"/>
<!-- CSS for Demo Purpose, don't include it in your project -->
<link href="assets/css/demo.css" rel="stylesheet" />
<!-- Fonts and icons -->
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.2.0/css/font-awesome.min.css" rel="stylesheet">
<link href='//fonts.googleapis.com/css?family=Roboto:400,700,300' rel='stylesheet' type='text/css'>
<link href="assets/css/pe-icon-7-stroke.css" rel="stylesheet" />
</head>
<body>
<div class="wrapper">
<div class="sidebar" data-color="blue" data-image="http://www.zastavki.com/pictures/originals/2015/Creative_Wallpaper_Set_of_business_people_100390_.jpg">
<!-- you can change the color of the sidebar using: data-color="blue | azure | green | orange | red | purple" -->
<div class="sidebar-wrapper">
<div class="pic"></div>
<div class="logo">
<a href="#">
<span style="font-size: 28px;">Hello <span style="font-weight: bold;"><?php echo $first_name.' '.$last_name; ?>!</span></span>
</a>
</div>
<ul class="nav">
<li>
<a href="dashboard.php">
<i class="pe-7s-graph"></i>
<p>Dashboard</p>
</a>
</li>
<li class="active">
<a href="user.html">
<i class="pe-7s-user"></i>
<p>User Profile</p>
</a>
</li>
</ul>
</div>
</div>
<div class="main-panel">
<nav class="navbar navbar-default navbar-fixed">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#navigation-example-2">
<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="#">Profile</a>
</div>
<div class="collapse navbar-collapse">
<ul class="nav navbar-nav navbar-left">
<li>
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-dashboard"></i>
</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<i class="fa fa-globe"></i>
<b class="caret"></b>
<span class="notification">5</span>
</a>
<ul class="dropdown-menu">
<li>Notification 1</li>
<li>Notification 2</li>
<li>Notification 3</li>
<li>Notification 4</li>
<li>Another notification</li>
</ul>
</li>
<li>
<a href="">
<i class="fa fa-search"></i>
</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="">
Account
</a>
</li>
<li class="dropdown">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
Dropdown
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li>Action</li>
<li>Another action</li>
<li>Something</li>
<li>Another action</li>
<li>Something</li>
<li class="divider"></li>
<li>Separated link</li>
</ul>
</li>
<li>
<a href="index.php">
Log out
</a>
</li>
</ul>
</div>
</div>
</nav>
<div class="content">
<div class="container-fluid">
<div class="row">
<div class="col-md-8">
<div class="card">
<div class="header">
<h4 class="title">Edit Profile</h4>
</div>
<div class="content">
<form method="POST" action="action.php">
<div class="row">
<div class="col-md-5">
<div class="form-group">
<label>Company (disabled)</label>
<input type="text" class="form-control" disabled placeholder="Company" value="Creative Code Inc.">
</div>
</div>
<div class="col-md-3">
<div class="form-group">
<label>Username</label>
<input name="username" type="text" class="form-control" placeholder="Username" value="<?php echo $username; ?>">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label for="exampleInputEmail1">Email address</label>
<input type="email" class="form-control" placeholder="Email" value="<?php echo $email; ?>">
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label>First Name</label>
<input type="text" name="first_name" class="form-control" placeholder="Company" value="<?php echo $first_name; ?>">
</div>
</div>
<div class="col-md-6">
<div class="form-group">
<label>Last Name</label>
<input type="text" name="last_name" class="form-control" placeholder="Last Name" value="<?php echo $last_name; ?>">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>Address</label>
<input type="text" name="address" class="form-control" placeholder="Home Address" value="Bld Mihail Kogalniceanu, nr. 8 Bl 1, Sc 1, Ap 09">
</div>
</div>
</div>
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label>City</label>
<input type="text" name="city" class="form-control" placeholder="City" value="<?php echo $_SESSION['city']; ?>">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Country</label>
<input type="text" name="country" class="form-control" placeholder="Country" value="Andrew">
</div>
</div>
<div class="col-md-4">
<div class="form-group">
<label>Postal Code</label>
<input type="number" class="form-control" placeholder="ZIP Code">
</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<div class="form-group">
<label>About Me</label>
<textarea name="aboutme" rows="5" class="form-control" placeholder="Here can be your description" value="Mike">Lamborghini Mercy, Your chick she so thirsty, I'm in that two seat Lambo.</textarea>
</div>
</div>
</div>
<button type="submit" class="btn btn-info btn-fill pull-right">Update Profile</button>
<div class="clearfix"></div>
</form>
</div>
</div>
</div>
<div class="col-md-4">
<div class="card card-user">
<div class="image">
<img src="https://ununsplash.imgix.net/photo-1431578500526-4d9613015464?fit=crop&fm=jpg&h=300&q=75&w=400" alt="..."/>
</div>
<div class="content">
<div class="author">
<a href="#">
<img class="avatar border-gray" src="assets/img/faces/face-3.jpg" alt="..."/>
<h4 class="title"><?php echo $first_name; ?><br />
<small><?php echo $username; ?></small>
</h4>
</a>
</div>
<p class="description text-center"> "Lamborghini Mercy <br>
Your chick she so thirsty <br>
I'm in that two seat Lambo"
</p>
</div>
<hr>
<div class="text-center">
<button href="#" class="btn btn-simple"><i class="fa fa-facebook-square"></i></button>
<button href="#" class="btn btn-simple"><i class="fa fa-twitter"></i></button>
<button href="#" class="btn btn-simple"><i class="fa fa-google-plus-square"></i></button>
</div>
</div>
</div>
</div>
</div>
</div>
<footer class="footer">
<div class="container-fluid">
<nav class="pull-left">
<ul>
<li>
<a href="#">
Home
</a>
</li>
<li>
<a href="#">
Company
</a>
</li>
<li>
<a href="#">
Portfolio
</a>
</li>
<li>
<a href="#">
Blog
</a>
</li>
</ul>
</nav>
<p class="copyright pull-right">
© 2016 Creative Tim, made with love for a better web
</p>
</div>
</footer>
</div>
</div>
</body>
<!-- Core JS Files -->
<script src="assets/js/jquery-1.10.2.js" type="text/javascript"></script>
<script src="assets/js/bootstrap.min.js" type="text/javascript"></script>
<!-- Checkbox, Radio & Switch Plugins -->
<script src="assets/js/bootstrap-checkbox-radio-switch.js"></script>
<!-- Charts Plugin -->
<script src="assets/js/chartist.min.js"></script>
<!-- Notifications Plugin -->
<script src="assets/js/bootstrap-notify.js"></script>
<!-- Google Maps Plugin -->
<script type="text/javascript" src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<!-- Light Bootstrap Table Core javascript and methods for Demo purpose -->
<script src="assets/js/light-bootstrap-dashboard.js"></script>
<!-- Light Bootstrap Table DEMO methods, don't include it in your project! -->
<script src="assets/js/demo.js"></script>
</html>
I know the code is not secure, this is just for test purposes. Help is highly appreciated.
Hye i have a problem with my php addadmin form. I tried several coding which i found on the internet, but most of them generate a same result, php coding dosent shows any error, but the data failed to insert into phpmyadmin database
here is my coding form
<?php
session_start();
include('function.php');
include('database.php');
checksession(899);
$userid = $_SESSION['userid'];
$query_getdetail = mysql_query("SELECT * FROM userdetail WHERE userid = $userid");
$row = #mysql_fetch_array($query_getdetail);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Admin Front Page</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/datepicker3.css" rel="stylesheet">
<link href="css/styles.css" rel="stylesheet">
<!--Icons-->
<script src="js/lumino.glyphs.js"></script>
<script src="js/jquery-1.11.1.min.js"></script>
<script src="js/bootstrap.min.js"></script>
<script type="text/javascript" src="js/noty/packaged/jquery.noty.packaged.min.js"></script>
<!--[if lt IE 9]>
<script src="js/html5shiv.js"></script>
<script src="js/respond.min.js"></script>
<![endif]-->
</head>
<body>
<nav class="navbar navbar-inverse navbar-fixed-top" role="navigation">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" 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="#"><span>Admin</span><?php echo " " . $row['firstname'] . " " . $row['lastname']; ?></span> </a>
<ul class="user-menu">
<li class="dropdown pull-right">
<svg class="glyph stroked male-user"><use xlink:href="#stroked-male-user"></use></svg> User <span class="caret"></span>
<ul class="dropdown-menu" role="menu">
<li><svg class="glyph stroked male-user"><use xlink:href="#stroked-male-user"></use></svg> Profile</li>
<li><svg class="glyph stroked cancel"><use xlink:href="#stroked-cancel"></use></svg> Logout</li>
</ul>
</li>
</ul>
</div>
</div><!-- /.container-fluid -->
</nav>
<div id="sidebar-collapse" class="col-sm-3 col-lg-2 sidebar">
<form role="search">
<div class="form-group">
<input type="text" class="form-control" placeholder="Search">
</div>
</form>
<ul class="nav menu">
<li><svg class="glyph stroked dashboard-dial"><use xlink:href="#stroked-dashboard-dial"></use></svg> Dashboard</li>
<li><svg class="glyph stroked calendar"><use xlink:href="#stroked-calendar"></use></svg> Message </li>
<li class="active"><svg class="glyph stroked male user "><use xlink:href="#stroked-male-user"/></svg> Add Admin</li>
<li><svg class="glyph stroked table"><use xlink:href="#stroked-table"></use></svg> Events</li>
<li><svg class="glyph stroked pencil"><use xlink:href="#stroked-pencil"></use></svg> View Members</li>
</ul>
</div><!--/.sidebar-->
<div class="col-sm-9 col-sm-offset-3 col-lg-10 col-lg-offset-2 main">
<div class="row">
<ol class="breadcrumb">
<li><svg class="glyph stroked home"><use xlink:href="#stroked-home"></use></svg></li>
<li class="active">Add Admin</li>
</ol>
</div><!--/.row-->
<div class="row">
<div class="col-lg-12">
<h1 class="page-header">Add Admin</h1>
</div>
</div><!--/.row-->
<div class="row">
<div class="col-lg-12">
<div class="panel panel-default">
<div class="panel-heading">Only add an Authorised User</div>
<div class="panel-body">
<div class="col-md-6">
<form role="form">
<div class="form-group">
<form action="<?php echo $_SERVER["PHP_SELF"];?>" method="post" enctype="multipart/form-data">
<label>Username</label>
<input class="form-control" name="new_user" required>
</div>
<div class="form-group">
<label>Password</label>
<input type="password" name="pass_1" class="form-control" required>
</div>
<div class="form-group">
<label>Reconfirm Password</label>
<input type="password" name="pass_2" class="form-control" required>
</div>
<button type="submit" class="btn btn-primary" id="save" name="save" value="save">Submit Button</button>
<button type="reset" class="btn btn-default" value="reset">Reset Button</button>
</div>
</form>
</div>
</div>
</div>
and this is my php connectivity to mysql coding
<?php
$conn=mysql_connect("localhost", "root","")or die("Couldn't connect to the server");
$db=mysql_select_db("fyp", $conn) or die("Couldn't connect to the database");
if(isset($_POST['save'])){
$user_temp = $_POST['new_user'];
$pass1_temp = $_POST['pass_1'];
$pass2_temp = $_POST['pass_2'];
if($pass1_temp != $pass2_temp){
?>
<script>
alert("Passwords not matched");
</script>
<?php
}
else{
$query = mysql_query("INSERT INTO login(username,password,type) VALUES ('$user_temp', sha1('$pass1_temp'), 899) ");
if($query){
?>
<script>
alert("New admin added");
</script>
<?php
}
else {
}
}
}
?>
i put the php form coding and and process form coding all together in one page. If anyone can help me im so appreciate with your kindness. Thank you
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