The footer of my website's homepage isn't coming - php

I have been trying to make a website. It is an online shopping website.
This is my code-
<?php
session_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Books And Beyond</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<!-- Bootstrap styles open source -->
<link href="//netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css" rel="stylesheet" crossorigin="anonymus">
<!-- Customize styles -->
<link href="style.css" rel="stylesheet"/>
<!-- font awesome styles open source -->
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css" crossorigin="anonymus">
<!-- Favicons -->
<link rel="shortcut icon" href="/favicon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"><style
type="text/css">
<!--
body {
background-image: url(assets/img/background.jpg);
}
-->
</style></head>
<body>
<!--
Upper Header Section
-->
<div class="navbar navbar-inverse navbar-fixed-top">
<div class="topNav">
<div class="container">
<div class="alignR">
<?php if (isset($_SESSION['email'])) { echo $_SESSION['email']; } else { ?>
<ul class="nav pull-right">
<li class="dropdown">
<a data-toggle="dropdown" class="dropdown-toggle" href="#"><span class="icon-lock"></span> Login <b class="caret"></b></a>
<div class="dropdown-menu">
<form class="form-horizontal loginFrm" action="checkuser.php" method="post">
<div class="control-group">
<input name="email" type="text" class="span2" id="email" placeholder="Email">
</div>
<div class="control-group">
<input name="password" type="password" class="span2" id="password" placeholder="Password">
</div>
<div class="control-group">
<label class="checkbox">
<input type="checkbox"> Remember me
</label>
<button name="login" type="submit" class="shopBtn btn-block">Sign in</button>
</div>
</form>
</div>
</li>
</ul>
<?php } ?>
<?php if (isset($_SESSION['email'])) { ?>
Logout
<?php } else { ?>
<span class="icon-edit"></span> Register
<?php }?>
</div>
</div>
</div>
</div>
<!--
Lower Header Section
-->
<div class="container">
<div id="gototop"> </div>
<header id="header">
<div class="row">
<div class="span4">
<h1>
<a class="logo" href="index.php"><span>Books And Beyond</span>
<img src="assets/img/logo1.jpg" alt="" width="218" height="94"> </a> </h1>
</div>
</div>
</header>
<!--
Navigation Bar Section
-->
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<div class="nav-collapse">
<ul class="nav">
<li class="active">Home</li>
<li class="">About</li>
<li class="">Bargain Books</li>
<li class="">New Releases</li>
<li class="">Bestsellers</li>
<li class="">Contact Us</li>
</ul>
<ul class="nav pull-right">
</ul>
</div>
</div>
</div>
</div>
<div class="row">
<div class="span12">
<img src="assets/img/banner.jpg"/>
<hr class="soften"/>
</div>
</div>
<!--Body Section
-->
<div class="row">
<div id="sidebar" class="span3">
<div class="well well-small">
<h3> Category </h3>
<ul class="nav nav-list">
<li><span class="icon-chevron-right"></span>Fiction</li>
<li><span class="icon-chevron-right"></span>Non-Fiction</li>
<li><span class="icon-chevron-right"></span>Young Adult</li>
<li><span class="icon-chevron-right"></span>Children's</li>
<li><span class="icon-chevron-right"></span>Travel</li>
<li><span class="icon-chevron-right"></span>Education</li>
<li style="border:0"> </li>
</ul>
</div>
<!--<div class="well well-small alert alert-warning cntr">
<h2>50% Discount</h2>
<p>
only valid for online order. <br><br><a class="defaultBtn" href="#">Click here </a>
</p>
</div>-->
<!-- <div class="well well-small" ><img src="assets/img/paypal.jpg" alt="payment method paypal"></div>-->
<!--<a class="shopBtn btn-block" href="#">Upcoming products <br><small>Click to view</small></a>-->
<ul class="nav nav-list promowrapper">
<?php
/* require_once('dbconnect.php'); */
$result = mysql_query("SELECT * from product WHERE brand='accessories'");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
$price=$row["productprice"];
$productimage=$row["productimage"];
?>
<li>
<div class="thumbnail">
<img width="200" height="80" src="getImage.php?intproductid=<?php print $intproductid;?>" />
<div class="caption">
<table width="250" border="0">
<tr>
<td align="left" valign="middle"><form action="product_detail.php" method="post" name="form2" id="form2">
<label>
<input type="hidden" name="intproductid2" value="<?php echo $intproductid; ?>" />
<input name="Submit2" type="submit" class="shopBtn" value="View" />
</label>
</form></td>
<td align="right" valign="middle"><h4> <span class="pull-right"><?php echo $price; ?>.00</span></h4></td>
</tr>
</table>
</div>
</div>
</li>
<li style="border:0"> </li>
<?php } ?>
</ul>
</div>
<div class="span9">
<!--
New Products
-->
<div class="well well-small">
<h3>New Products </h3>
<hr class="soften"/>
<div class="row-fluid">
<div id="newProductcar" class="carousel slide">
<div class="">
<div class="item active">
<ul class="thumbnails">
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='bousni' LIMIT 1");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
//$productimage=$row["productimage"];
?>
<li class="span3">
<div class="thumbnail">
<img width="200" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
</div>
</li>
<?php } ?>
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='hela couture' LIMIT 1");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
//$productimage=$row["productimage"];
?>
<li class="span3">
<div class="thumbnail">
<img width="200" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
</div>
</li>
<?php } ?>
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='zey' LIMIT 1");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
//$productimage=$row["productimage"];
?>
<li class="span3">
<div class="thumbnail">
<img width="200" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
</div>
</li>
<?php } ?>
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='AL-JUMAIRA' LIMIT 1");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
//$productimage=$row["productimage"];
?>
<li class="span3">
<div class="thumbnail">
<img width="200" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
</div>
</li>
<?php } ?>
</ul>
</div>
</div>
</div>
</div>
</div>
<div class="well well-small">
<div class="span8">
<div class="row-fluid">
<h3>Features Products </h3>
<hr class="soften"/>
<ul class="thumbnails">
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='roza' LIMIT 3");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
$productname=$row["productname"];
$brand=$row["brand"];
$price=$row["productprice"];
$productimage=$row["productimage"];
?>
<li class="span4">
<div class="thumbnail">
<img width="250" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
<div class="caption cntr">
<p style="color:#990033"><?php echo $productname; ?></p>
<p><?php echo $brand; ?></p>
<p><strong>SAR <?php echo $price; ?>.00</strong></p>
<div class="btn-group">
<form id="form2" name="form2" method="post" action="product_detail.php">
<label>
<input type="hidden" name="intproductid2" value="<?php echo $intproductid; ?>" />
<input name="Submit2" type="submit" class="shopBtn" value="View" />
<input name="Submit2" type="submit" class="defaultBtn" value="Add to cart" />
</label>
</form>
</div>
<br class="clr">
</div>
</div>
</li>
<?php } ?>
</ul>
<hr class="soften"/>
<ul class="thumbnails">
<?php
require_once('dbconnect.php');
$result = mysql_query("SELECT * from product WHERE brand='haya' LIMIT 3");
while ($row = mysql_fetch_array($result))
{
$intproductid=$row["id"];
$productname=$row["productname"];
$brand=$row["brand"];
$price=$row["productprice"];
$productimage=$row["productimage"];
?>
<li class="span4">
<div class="thumbnail">
<img width="250" height="120" src="getImage.php?intproductid=<?php print $intproductid;?>" />
<div class="caption cntr">
<p style="color:#990033"><?php echo $productname; ?></p>
<p><?php echo $brand; ?></p>
<p><strong>SAR <?php echo $price; ?>.00</strong></p>
<div class="btn-group">
<form id="form2" name="form2" method="post" action="product_detail.php">
<label>
<input type="hidden" name="intproductid2" value="<?php echo $intproductid; ?>" />
<input name="Submit2" type="submit" class="shopBtn" value="View" />
<input name="Submit2" type="submit" class="defaultBtn" value="Add to cart" />
</label>
</form>
</div>
<br class="clr">
</div>
</div>
</li>
<?php } ?>
</ul>
</div>
</div>
<div class="row">
</div>
</div>
</div></div></div>
<!--
Footer
-->
<footer class="footer" style="float: bottom;">
<div class="row-fluid">
<div class="span3">
<h5>ORDER SUPPORT</h5>
Store pickup<br>
Return and Refund<br>
</div>
<div class="span3">
<h5>PRODUCT SUPPORT</h5>
FAQs<br>
Inquiry<br>
</div>
<div class="span3">
<h5>COOPORATIVE INFO</h5>
Terms and Condition <br>
Contact us<br>
</div>
<div class="span3">
<h5>GET CONNECTED</h5>
About us <br>
Create Account<br>
</div>
</div>
</footer>
</div><!-- /container -->
<div class="copyright">
<div class="container">
<p class="pull-right"> </p>
<span>Copyright 2019, Fatimatuz Johura - s201403034- Jeddah (Ladies Branch);<br> Books And Beyond</span>
</div>
</div>
<script src="assets/js/jquery.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
<script src="assets/js/jquery.easing-1.3.min.js"></script>
<script src="assets/js/jquery.scrollTo-1.4.3.1-min.js"></script>
<script src="assets/js/shop.js"></script>
</body>
</html>
The 'New Products' and the footer section is not coming and I cant figure out why. I dont have a webhost yet so I am using localhost for now. I have tried editing the code but whatever I do, it does not seem to work. If anyone can help, I would really appreciate it. Thank you.

On line 152 (new products is on line ~ 185[ish])
/* require_once('dbconnect.php'); */
$result = mysql_query("SELECT * from product WHERE brand='accessories'");
As I said in the comments you use this require_once('dbconnect.php'); multiple times when it should be only once at the top of your file.
The above code is the first occurrence I could find, and as it's commented out, that query is going to bomb out on you. Execution happens top to bottom and the first uncommitted occurrence of that is line 196[ish], which is way to late for that first query.
Also as I said in the comments
Try turning on Error reporting - error_reporting(-1); and ini_set('display_errors', '1'); put those right after the <?php tag
You can save yourself, and us a lot of time that way.
So in Summery,
Remove all of these require_once('dbconnect.php'); and then add just one after the opening <?php tag.
PS you can easily test this, by just commenting that first query out, or by uncommenting that first require_once.

Related

My pictures don't show up in my index.php file

I am creating a shopping cart in mySQLi and PHP. I inserted the products with images into PhpMyAdmin (I typed - zdjecia/photo.png in the zdjecie_produktu)
This is my code for this part in PHP. I am only starting PHP and I've been following this tutorial https://www.youtube.com/watch?v=ka2ea2LL36g. Everything seems to work fine, just these pictures don't show up :(
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>x</title>
<link rel="stylesheet" href="style.css">
<link rel="preconnect" href="https://fonts.gstatic.com">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght#300;400;500;600;700&display=swap" rel="stylesheet">
<link rel="shortcut icon" href="favico.png" />
</head>
<body>
<section class="home">
<div class="slider">
<div class="slide active" id="slide" style="background-image: url(tlo1.jpg)" ><div class="header">
<div class="container">
<div class="navbar">
<div class="darmowadostawa">
<p>100% WYRÓB DOMOWY | Gwarancja komfortu</p>
</div>
<div class="emailugory">
E-mail:xxx
Numer telefonu:xxx-xxx-xxx
</div>
<nav class="indeksik">
<ul id="MenuItems">
<li class="logo"><img src="logooficjalne.png" class="carolinepng"></li>
<li>O nas</li>
<li>Świece świąteczne</li>
<li>Naturalne świece zapachowe</li>
<li>Świece zapachowe w szkle</li>
<li>Zapachy
<ul>
<li>Owocowe</li>
<li>Słodkie</li>
<li>Eleganckie</li>
<li>Kwiatowe</li>
<li>Świąteczne</li>
</ul>
</li>
<li>Blog</li>
<li class="cart"> <i class="fab fa-opencart"><img src="cart.png" width="20px" margin-top="0px;"></i><span class="cart-span">0</span> </li>
</ul>
</nav>
<img src="menu.png" class="menu-icon" onclick="menutoggle()">
</div>
<div class="caption">
<h1 class="nowysklep">NOWY SKLEP</h1>
<p>Świece Caroline Homemade Candles to nowa marka domowych świec zapachowych. Nasze świece produkowane są ręcznie w zaciszu domowym z naturalnego wosku sojowego.</p>
Kup teraz
</div>
</div>
</div>
</div>
<div class="slide" id="slide" style="background-image: url(tlo2.jpg)"><div class="header">
<div class="container">
<div class="navbar">
<div class="darmowadostawa">
<p>100% WYRÓB DOMOWY | Gwarancja komfortu</p>
</div>
<div class="emailugory">
E-mail:xxx
Numer telefonu:xxx-xxx-xxx
</div>
<nav>
<ul id="MenuItems">
<li class="logo"><img src="logooficjalne.png" class="carolinepng"></li>
<li>O nas</li>
<li>Świece świąteczne</li>
<li>Naturalne świece zapachowe</li>
<li>Świece zapachowe w szkle</li>
<li>Zapachy
<ul>
<li>Owocowe</li>
<li>Słodkie</li>
<li>Eleganckie</li>
<li>Kwiatowe</li>
<li>Świąteczne</li>
</ul>
</li>
<li>Blog</li>
<li class="cart"> <i class="fab fa-opencart"><img src="cart.png" width="20px" margin-top="0px;"></i><span class="cart-span">0</span> </li>
</ul>
</nav>
<img src="menu.png" class="menu-icon" onclick="menutoggle()">
</div>
<div class="caption">
<h1 class="darmowa">DARMOWA DOSTAWA OD 100ZŁ</h1>
<p>Darmowa dostawa już od 100zł.<br> Dostępny Kurier/Paczkomaty Inpost.</p>
</div>
</div>
</div>
</div>
<div class="slide" id="slide" style="background-image: url(tlo3.jpg)" ><div class="header">
<div class="container">
<div class="navbar">
<div class="darmowadostawa">
<p>100% WYRÓB DOMOWY | Gwarancja komfortu</p>
</div>
<div class="emailugory">
E-mail:xxx
Numer telefonu:xxx-xxx-xxx
</div>
<nav>
<ul id="MenuItems">
<li class="logo"><img src="logooficjalne.png" class="carolinepng"></li>
<li>O nas</li>
<li>Świece świąteczne</li>
<li>Naturalne świece zapachowe</li>
<li>Świece zapachowe w szkle</li>
<li>Zapachy
<ul>
<li>Owocowe</li>
<li>Słodkie</li>
<li>Eleganckie</li>
<li>Kwiatowe</li>
<li>Świąteczne</li>
</ul>
</li>
<li>Blog</li>
<li class="cart"> <i class="fab fa-opencart"><img src="cart.png" width="20px" margin-top="0px;"></i><span class="cart-span">0</span> </li>
</ul>
</nav>
<img src="menu.png" class="menu-icon" onclick="menutoggle()">
</div>
<div class="caption">
<h1 class="przyjemnosc">ŚWIAT PRZYJEMNOŚĆI</h1>
<p>Świece Caroline Homemade Candles są naturalne jak i również ekologiczne. Swój produkt tworzymy z pasją i zamiłowaniem. Zapraszamy Cię do naszego świata przyjemności</p>
Kup teraz
</div>
</div>
</div>
</div>
</div>
<div class="controls">
<div class="prev"><</div>
<div class="next">></div>
</div>
<div class="indicator">
</div>
</section>
<!-----featured categories ------->
<div class="categories">
<div class="small-container">
<div class="row">
<div class="col-3">
<img src="categories-1.png">
</div>
<div class="col-3">
<img src="categories-2.png">
</div>
<div class="col-3">
<img src="categories-3.png">
</div>
</div>
</div>
</div>
<!----- featured products----->
<div class="container">
<div class="row">
<?php
include 'config.php';
$stmt = $conn->prepare("SELECT * FROM product");
$stmt->execute();
$result = $stmt->get_result();
while($row = $result->fetch_assoc());
?>
<div class="col-lg-3">
<div class="card-deck">
<div class="card p-2 border-secondary mb-2">
<img src="<?= $row['zdjecie_produktu'] ?>" class="card-img-top" height="250">
</div>
</div>
</div>
<?php T_ENDWHILE ?>
</div>
</div>
<!----- footer ----->
<footer>
<div class="column">
<ul class="footer-links-main">
<li>O nas</li>
<li>Produkty</li>
<li>Regulamin</li>
<li>Kontakt</li>
<li>FAQ</li>
</ul>
</div>
<div class="footer-sm">
<div class="column2">
<h3 class="kontakth3">Kontakt</h3>
<p class="kontaktp">Adres e-mail:xxx</p>
<p class="kontaktp">Numer telefonu:xxx</p>
</div>
</div>
</footer>
<!---- js for toggle menu--->
<script>
var MenuItems = document.getElementById("MenuItems");
MenuItems.style.maxHeight = "0px";
function menutoggle(){
if (MenuItems.style.maxHeight == "0px")
{
MenuItems.style.maxHeight = "200px";
}
else
{
MenuItems.style.maxHeight = "0px";
}
}
</script>
<script src="main.js"></script>
<script src="https://unpkg.com/ionicons#5.2.3/dist/ionicons.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<!-- Popper JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
</body>
</html>
The code has no errors and a default broken image icon shows up instead of pictures.
and this is my config.php
<?php
$conn = new mysqli("localhost","root","","cart_system");
if($conn->connect_error){
die("Connection Failed".$conn->connect_error);
}
?>

.php files working on localhost but not on webserver

I've created some kind of webshop for my highschool project. After building a filter system that searches through my database and loads them with the help of my self-written class product loader.
To set the filtervariables I've worked with $_GET. Everything is working perfectly fine on my localhost but when uploading to the server posed by my highschool only the header which I'm "requiring" separately works but anything else won't load.
Might it be that the server doesn't allow $_GET methods?
<?php
$current_page = 'Webshop.php';
require 'header.php';
require 'includes\productloader.inc.php';
?>
<body>
<form method="get"action="Webshop.php">
<aside class="EDside">
<div class="Filtersidebar">
<h1>Filter</h1>
<ul class="Filter">
<li><a>Max. Höhe</a></li>
<li><a>Max. Breite</a></li>
<li><a>Max. Tiefe</a></li>
<li><a>Metallart</a></li>
<li><a>Max. Preis</a></li>
<li><input type="text" name="Höhe" value=""></li>
<li><input type="text" name="Breite" value=""></li>
<li><input type="text" name="Tiefe" value=""></li>
<li><select id="Metallart" name="Metallart">
<option value=""></option>
<option value="Bronze">Bronze</option>
<option value="Messing">Messing</option>
<option value="Kupfer">Kupfer</option>
<option value="Edelstahl">Edelstahl</option>
<option value="Aluminium">Aluminium</option>
<option value="Rostig">Rostig</option>
</select></li>
<li><input type="text" name="Preis" value=""></li>
</ul>
</div>
<div>
<a href = Webshop.php><button>Zurücksetzen</button></a>
<button type ="submit" >Anwenden</button>
</div>
</aside>
</form>
<?php
if(isset($_GET['Höhe'])){
$maxhöhe;
if(!$_GET['Höhe']=="")
$maxhöhe = $_GET['Höhe'];
else
$maxhöhe = null;
if(!$_GET['Breite']=="")
$maxbreite = $_GET['Breite'];
else
$maxbreite = null;
if(!$_GET['Tiefe']=="")
$maxtiefe = $_GET['Tiefe'];
else
$maxtiefe = null;
$metallart;
if(!$_GET['Metallart']=="")
$metallart = $_GET['Metallart'];
else
$metallart = null;
$maxpreis;
if(!$_GET['Preis']=="")
$maxpreis = $_GET['Preis'];
else
$maxpreis = null;
if($maxhöhe == null && $maxbreite == null && $maxtiefe == null && $metallart == null && $maxpreis == null)
$loader = productloader::withoutstatement();
else
$loader = productloader::withstatement($maxhöhe,$maxbreite,$maxtiefe,$metallart,$maxpreis);
}
else
$loader = productloader::withoutstatement();
$productcount = count($loader->products);
?>
<?php
if($productcount>0){
echo '
<section class="EDSection">
<ul class="Skulptur">
<li> <div class = "SBox">
<div class="angebote">
<div class="angebot-bild">
<img class="a01" src="showimage.php?id='.$loader->products[0]->imgid.'" />
</div>
<div class="angebot-text">
<h1>'.$loader->products[0]->productname.'</h1>
</div>
<div class="angebot-preis">
<p>'.$loader->products[0]->preis.' EUR</p>
</div>
</div>
</div>
</li>
';
}
if($productcount>1){
echo '
<li><div class = "SBox">
<div class="angebote">
<div class="angebot-bild">
<img class="a01" src="showimage.php?id='.$loader->products[1]->imgid.'" />
</div>
<div class="angebot-text">
<h1>'.$loader->products[1]->productname.'</h1>
</div>
<div class="angebot-preis">
<p>'.$loader->products[1]->preis.' EUR</p>
</div>
</div>
</div>
</li>
';
}
if($productcount>2){
echo '
<li><div class = "SBox">
<div class="angebote">
<div class="angebot-bild">
<img class="a01" src="showimage.php?id='.$loader->products[2]->imgid.'" />
</div>
<div class="angebot-text">
<h1>'.$loader->products[2]->productname.'</h1>
</div>
<div class="angebot-preis">
<p>'.$loader->products[2]->preis.' EUR</p>
</div>
</div>
</div>
</li>
';
}
if($productcount>3){
echo '
<li><div class = "SBox">
<div class="angebote">
<div class="angebot-bild">
<img class="a01" src="showimage.php?id='.$loader->products[3]->imgid.'" />
</div>
<div class="angebot-text">
<h1>'.$loader->products[3]->productname.'</h1>
</div>
<div class="angebot-preis">
<p>'.$loader->products[3]->preis.' EUR</p>
</div>
</div>
</div>
</li>
';
}
if($productcount>4){
echo'
<li> <div class = "SBox">
<div class="angebote">
<div class="angebot-bild">
<img class="a01" src="showimage.php?id='.$loader->products[4]->imgid.'" />
</div>
<div class="angebot-text">
<h1>'.$loader->products[4]->productname.'</h1>
</div>
<div class="angebot-preis">
<p>'.$loader->products[4]->preis.' EUR</p>
</div>
</div>
</div>
</li>
';
}
if($productcount>5){
echo ' <li><div class = "SBox">
<div class="angebote">
<div class="angebot-bild">
<img class="a01" src="showimage.php?id='.$loader->products[5]->imgid.'" />
</div>
<div class="angebot-text">
<h1>'.$loader->products[5]->productname.'</h1>
</div>
<div class="angebot-preis">
<p>'.$loader->products[5]->preis.' EUR</p>
</div>
</div>
</div>
</li>';
}
if($productcount>6){
echo ' <li><div class = "SBox">
<div class="angebote">
<div class="angebot-bild">
<img class="a01" src="showimage.php?id='.$loader->products[6]->imgid.'" />
</div>
<div class="angebot-text">
<h1>'.$loader->products[6]->productname.'</h1>
</div>
<div class="angebot-preis">
<p>'.$loader->products[6]->preis.' EUR</p>
</div>
</div>
</div>
</li>';
}
if($productcount>7){
echo ' <li><div class = "SBox">
<div class="angebote">
<div class="angebot-bild">
<img class="a01" src="showimage.php?id='.$loader->products[7]->imgid.'" />
</div>
<div class="angebot-text">
<h1>'.$loader->products[7]->productname.'</h1>
</div>
<div class="angebot-preis">
<p>'.$loader->products[7]->preis.' EUR</p>
</div>
</div>
</div>
</li>';
}
?>
</section>
<section>
<div style="text-align: center">
<ul class="pagination">
<li>«</li>
<li><a class="active" href="Webshop.php">1</a></li>
<li>2</li>
<li>3</li>
<li>»</li>
</ul>
</div>
</section>
<?php
require 'footer.php';
?>
</body>
</html>

dropdown is not selecting selected option in php while editing

i'm selecting option while adding,but selected option is not in edit dropdown.What will be the issue?
Edit Appointment.php:
<?php
include_once 'config.php';
$id = $_REQUEST['id'];
$query="SELECT p.*,u.fileno FROM patients AS p,users AS u WHERE p.id_patient='$id' AND p.users_id_user=u.id_user";
$resultPatient=$db->select($query);
if(isset($_POST['requesttype'])&&$_POST['requesttype'] == 'editPatient'){
$updateInfo=array();
$updateInfo['name'] = $_REQUEST['name'];
$updateInfo['email'] = $_REQUEST['email'];
$updateInfo['age'] = $_REQUEST['age'];
/*$updateInfo['age'] = $_REQUEST['age'];
$updateInfo['gender'] = $_REQUEST['gender'];*/
$updateInfo['phone'] = str_replace(array('(',')',' ','-'), array('','','',''),$_REQUEST['phone']);
$updateInfo['date'] = date('d-m-Y', strtotime($_REQUEST['date']));
$updateInfo['time'] = $_REQUEST['time'];
$updateInfo['confirm_status'] = 'c';
$date=date('Y-m-d H:i:s');
$updateInfo['date_updated']=$date;
$updateCondition=" id_patient='".$id."'";
$res=$db->update('patients', $updateInfo,$updateCondition);
$id=$resultPatient[0]['users_id_user'];
$where="t.users_id_user='$id' AND";
$query="SELECT t.device_id,t.platforms_id_platform as id_platform FROM tokens as t WHERE $where t.device_id!=''";
$resultTokens=$db->select($query);
if($resultTokens)
{
include_once 'Gcm.php';
include_once 'Apns.php';
$deviceTokens=array();
$deviceTokens1=array();
$alert='Your appointment is confirmed on '.$updateInfo['date'].' at '.$updateInfo['time'];
foreach($resultTokens as $token)
{
if($token['id_platform']=='1'&&$token['device_id']!='')
$deviceTokens[]=$token['device_id'];
if($token['id_platform']=='2'&&$token['device_id']!='')
$deviceTokens1[]=$token['device_id'];
}
if(count($deviceTokens)>0)
{
$apns=new Apns();
$apns->apnsPush($deviceTokens,$alert);
}
if(count($deviceTokens1)>0)
{
$gcm = new GCM();
$message = array("m" => $alert);
$result = $gcm->send_notification($deviceTokens1,$message);
}
}
header("Location:appointments.php?m=u");
}
$querySlot = "SELECT * FROM slots";
$resultSlot=$db->select($querySlot);
$query="select * from photos where type='service'";
$resultUsers1=$db->select($query);
include_once 'header.php';
?>
<script type="text/javascript" src="js/jquery.timepicker.js"></script>
<link rel="stylesheet" type="text/css" href="js/jquery.timepicker.css" />
<script>
$(function() {
$('#basicExample').timepicker();
});
</script>
<!-- Sidebar begins -->
<div id="sidebar">
<!-- Left Main menu begins -->
<?php include_once 'menu.php'; ?>
<!-- Left Main menu ends -->
<!-- Secondary nav -->
<div class="secNav">
<div class="secWrapper">
<!--div class="secTop">
</div-->
<!-- Tabs container -->
<div id="tab-container" class="tab-container">
<div id="general">
<!-- Sidebar big buttons -->
<div id="general" style="display: block;" class="active">
<ul class="subNav">
<li><span class="icos-images2"></span>Add Appointment</li>
<li class="activeli"><span class="icos-images2"></span>View/Edit Appointments</li>
<li><span class="icos-images2"></span>Appointments History</li>
<li><span class="icos-images2"></span>View/Edit Reminder Settings</li>
<li><span class="icos-images2"></span>Add Reminder Settings</li>
<li><span class="icos-images2"></span>View/Edit Medicine Reminder Settings</li>
<li><span class="icos-images2"></span>Add Medicine Reminder Settings</li>
</ul>
</div>
</div>
</div>
</div>
<div class="clear"></div>
</div>
</div>
<!-- Sidebar ends -->
<!-- Content begins -->
<div id="content">
<div class="contentTop">
<span class="pageTitle"><span class="icon-screen"></span>Edit Appointment</span>
<div class="clear"></div>
</div>
<!-- Breadcrumbs line -->
<div class="breadLine">
<div class="bc">
<ul id="breadcrumbs" class="breadcrumbs">
<li>Dashboard</li>
<li>Appointments</li>
<li class="current">Edit Appointment</li>
</ul>
</div>
</div>
<!-- Main content -->
<div class="wrapper">
<div class="fluid">
<form name="formEditAppointment" id="usualValidate" class="main" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
<div class="widget grid6 chartWrapper" style="width:100%;min-height:550px;">
<div class="whead"><h6>Edit Appointment Information</h6><div class="clear"></div></div>
<div class="formRow">
<div class="grid3"><label>File No:<span class="req">*</span></label></div>
<div class="grid9"><?php echo stripslashes($resultPatient[0]['fileno']);?></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Name:<span class="req">*</span></label></div>
<div class="grid9"><input type="text" class="required" name="name" id="name" value="<?php echo stripslashes($resultPatient[0]['name']);?>"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Email:</label></div>
<div class="grid9"><input type="text" class="email" name="email" id="email" value="<?php echo stripslashes($resultPatient[0]['email']);?>"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Age:</label></div>
<div class="grid9"><input type="text" class="required" name="age" id="age" value="<?php echo stripslashes($resultPatient[0]['age']);?>"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Service:<span class="req">*</span></label></div>
<div class="grid9 searchDrop"><select data-placeholder="select service..." class="select" style="width: 100%" name="id_service">
<?php if($resultUsers1 && count($resultUsers1)>0)
foreach($resultUsers1 as $user)
{?>
<option value="<?php echo $user['id_photo']?>"<?php if($user['id_photo']==$user['title']) { ?> selected="selected" <?php } ?>><?php echo $user['title'];?></option>
<?php }?>
</select></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Phone:</label></div>
<div class="grid9"><input type="text" name="phone" id="phone" value="<?php echo stripslashes($resultPatient[0]['phone']);?>"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Date:</label></div>
<div class="grid9"><input type="text" class="required datepicker" name="date" id="date" value="<?php echo date('d-m-Y',strtotime($resultPatient[0]['date']));?>"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Time:</label></div>
<div class="grid9 searchDrop">
<input id="basicExample" type="text" name="time" class="time" value="<?php echo stripslashes($resultPatient[0]['time']);?>" style="width:80px"/>
</div>
<div class="clear"></div>
</div>
<input type="hidden" value="<?php echo $id; ?>" name="id" id="id_patient"/>
<input type="hidden" value="editPatient" name="requesttype"/>
<div class="formRow">
<div class="formSubmit">
<input class="buttonM bRed" id="next1" value="Save" type="submit">
<div class="clear"></div>
</div> <div class="clear"></div>
</div>
<div class="clear"></div></div>
</form>
</div>
</div>
<!-- Main content ends -->
</div>
<!-- Content ends -->
</body>
</html>
Add Appointment.php:
<?php
include_once 'config.php';
if(isset($_POST['requesttype'])&&$_POST['requesttype'] == 'addPatient'){
$insertInfo=array();
$insertInfo['users_id_user'] = $_REQUEST['id_user'];
$insertInfo['name'] = $_REQUEST['name'];
$insertInfo['email'] = $_REQUEST['email'];
$insertInfo['age'] = $_REQUEST['age'];
$insertInfo['gender'] = $_REQUEST['act'];
$insertInfo['service_id']=$_REQUEST['id_service'];
$insertInfo['phone'] = str_replace(array('(',')',' ','-'), array('','','',''),$_REQUEST['phone']);
$insertInfo['date'] = date('d-m-Y', strtotime($_REQUEST['date']));
$insertInfo['time'] = $_REQUEST['time'];
$insertInfo['confirm_status'] = 'c';
$date=date('Y-m-d H:i:s');
$insertInfo['date_created']=$date;
$insertInfo['date_updated']=$date;
$res=$db->insert('patients', $insertInfo);
$id=$_REQUEST['id_user'];
$where="t.users_id_user='$id' AND";
$query="SELECT t.device_id,t.platforms_id_platform as id_platform FROM tokens as t WHERE $where t.device_id!=''";
$resultTokens=$db->select($query);
if($resultTokens)
{
include_once 'Gcm.php';
include_once 'Apns.php';
$deviceTokens=array();
$deviceTokens1=array();
$alert='Your appointment is confirmed on '.$insertInfo['date'].' at '.$insertInfo['time'];
foreach($resultTokens as $token)
{
if($token['id_platform']=='1'&&$token['device_id']!='')
$deviceTokens[]=$token['device_id'];
if($token['id_platform']=='2'&&$token['device_id']!='')
$deviceTokens1[]=$token['device_id'];
}
if(count($deviceTokens)>0)
{
$apns=new Apns();
$apns->apnsPush($deviceTokens,$alert);
}
if(count($deviceTokens1)>0)
{
$gcm = new GCM();
$message = array("m" => $alert);
$result = $gcm->send_notification($deviceTokens1,$message);
}
}
header("Location:appointments.php?m=a");
}
$query="SELECT * FROM users";
$resultUsers=$db->select($query);
//$query="SELECT * FROM services";
$query="select * from photos where type='service'";
$resultUsers1=$db->select($query);
include_once 'header.php';
?>
<script type="text/javascript" src="js/jquery.timepicker.js"></script>
<link rel="stylesheet" type="text/css" href="js/jquery.timepicker.css" />
<script>
$(function() {
$('#basicExample').timepicker();
});
</script>
<!-- Sidebar begins -->
<div id="sidebar">
<!-- Left Main menu begins -->
<?php include_once 'menu.php'; ?>
<!-- Left Main menu ends -->
<!-- Secondary nav -->
<div class="secNav">
<div class="secWrapper">
<!--div class="secTop">
</div-->
<!-- Tabs container -->
<div id="tab-container" class="tab-container">
<div id="general">
<!-- Sidebar big buttons -->
<div id="general" style="display: block;" class="active">
<ul class="subNav">
<li class="activeli"><span class="icos-images2"></span>Add Appointment</li>
<li><span class="icos-images2"></span>View/Add Appointments</li>
<li><span class="icos-images2"></span>Appointments History</li>
<li><span class="icos-images2"></span>View/Add Reminder Settings</li>
<li><span class="icos-images2"></span>Add Reminder Settings</li>
<li><span class="icos-images2"></span>View/Add Medicine Reminder Settings</li>
<li><span class="icos-images2"></span>Add Medicine Reminder Settings</li>
</ul>
</div>
</div>
</div>
</div>
<div class="clear"></div>
</div>
</div>
<!-- Sidebar ends -->
<!-- Content begins -->
<div id="content">
<div class="contentTop">
<span class="pageTitle"><span class="icon-screen"></span>Add Appointment</span>
<div class="clear"></div>
</div>
<!-- Breadcrumbs line -->
<div class="breadLine">
<div class="bc">
<ul id="breadcrumbs" class="breadcrumbs">
<li>Dashboard</li>
<li>Appointments</li>
<li class="current">Add Appointment</li>
</ul>
</div>
</div>
<!-- Main content -->
<div class="wrapper">
<div class="fluid">
<form name="formAddAppointment" id="usualValidate" class="main" action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST" enctype="multipart/form-data">
<div class="widget grid6 chartWrapper" style="width:100%;min-height:680px;">
<div class="whead"><h6>Add Appointment Information</h6><div class="clear"></div></div>
<div class="formRow">
<div class="grid3"><label>File No:<span class="req">*</span></label></div>
<div class="grid9 searchDrop"><select data-placeholder="Choose a File No..." class="select" style="width: 100%" name="id_user">
<option value='0'>All</option>
<?php if($resultUsers && count($resultUsers)>0)
foreach($resultUsers as $user)
{?>
<option value="<?php echo $user['id_user']?>"><?php echo $user['fileno']?></option>
<?php }?>
</select></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Name:<span class="req">*</span></label></div>
<div class="grid9"><input type="text" class="required" name="name" id="name"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Email:</label></div>
<div class="grid9"><input type="text" class="email" name="email" id="email"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Age:</label></div>
<div class="grid9"><input type="text" class="required" name="age" id="age"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Sex:</label></div>
<div class="grid9 check"><label for="solve" class="mr20">Male:</label><input style="margin-top:5px;" type="radio" id="solve" name="act" value="m" class="required"/><label for="solve1" class="mr20">Female:</label><input style="margin-top:5px;" type="radio" id="solve1" name="act" value="f" /></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Service:<span class="req">*</span></label></div>
<div class="grid9 searchDrop"><select data-placeholder="select service..." class="select" style="width: 100%" name="id_service">
<option value='0'>All</option>
<?php if($resultUsers1 && count($resultUsers1)>0)
foreach($resultUsers1 as $user)
{?>
<option value="<?php echo $user['id_photo']?>"><?php echo $user['title']?></option>
<?php }?>
</select></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Phone:</label></div>
<div class="grid9"><input type="text" name="phone" id="phone" /></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Date:</label></div>
<div class="grid9"><input type="text" class="required datepicker" name="date" id="date" value="<?php echo date('d-m-Y',strtotime('now'));?>"/></div>
<div class="clear"></div>
</div>
<div class="formRow">
<div class="grid3"><label>Time:</label></div>
<div class="grid9 searchDrop">
<input id="basicExample" type="text" class="time" style="width:80px" name="time"/>
</div>
<div class="clear"></div>
</div>
<input type="hidden" value="addPatient" name="requesttype"/>
<div class="formRow">
<div class="formSubmit">
<input class="buttonM bRed" id="next1" value="Save" type="submit">
<div class="clear"></div>
</div> <div class="clear"></div>
</div>
<div class="clear"></div></div>
</form>
</div>
</div>
<!-- Main content ends -->
</div>
<!-- Content ends -->
</body>
</html>
Find this code <?php if($user['id_photo']==$user['title']) { ?>. You should check the database value with the option value when you edit. Replace with <?php if($user['id_photo']==$resultPatient[0]['id_photo']) { ?> and check.

Is it possible to get 'Session User" to display

Hi there I'm trying to get a user who comments and is logged in to their account for their 'Login Name' to display when they comment currenlty when a user wants to comment it asks for their name and their comment. Is it possible to display their name getting it from the session to display it? Thanks!
http://puu.sh/cByNU/697e58cdf6.jpg http://puu.sh/cByNU/697e58cdf6.jpg
On the image I'm logged in as 'Testing' is it possible to remove the field 'Name' and when they post a comment it will get their name where the search box is (testing).
Thanks!
My CODE:
<?php
session_start();
include "../includes/config.php";
include "function.php";
include ('../includes/header.php');
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Honda</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href='http://fonts.googleapis.com/css?family=Julius+Sans+One' rel='stylesheet' type='text/css'>
<link href="../css/style.css" rel="stylesheet" type="text/css" media="all" />
<!--start lightbox -->
<link rel="stylesheet" type="text/css" href="../css/jquery.lightbox.css">
<script src="../js/jquery.min.js"></script>
<script src="../js/jquery.lightbox.js"></script>
<script>
// Initiate Lightbox
$(function() {
$('.gallery1 a').lightbox();
});
</script>
</head>
<body>
<!--start header-->
<div class="h_bg">
<div class="wrap">
<div class="wrapper">
<div class="header">
<div class="logo">
<img src="../images/logo.png">
</div>
<div class="cssmenu">
<ul>
<li><span>Home</span></li>
<li><span>About</span></li>
<li class="active" class="has-sub"><span>Gallery</span>
</li>
<li class="last"><span>Contact</span></li>
<div class="clear"></div>
<form action="search.php" method="GET">
<div class="search">
<h2>search</h2>
<form>
<input type="text" name="query" placeholder="Enter Your search..." />
<input type="submit" value="">
</form>
</div>
</form>
<div class="search1">
<form action="" method="POST">
<br>
<h2>Welcome, <?=$_SESSION['sess_user'];?>!</h2><br><br>
<div class="pw">
<h3>Change details</h3>
</div>
<br><br>
<h2>Logout</h2>
</form>
</div>
</div>
</ul>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<!-- start content -->
<div class="content_bg">
<div class="wrap">
<div class="wrapper">
<div class="main">
<div class="ser-main">
<h2 class="style">Gallery of honda</h2>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic1.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic2.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic3.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic4.jpg" alt="">
</div>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<div class="footer_bg">
<div class="wrap">
<div class="wrapper">
<div class="footer">
<div class="search69">
<?php
if(isset($_POST['submit'])
&& !empty($_POST['name'])
&& !empty($_POST['comment']) ){
$name=$_POST['name'];
$comment=$_POST['comment'];
$submit=$_POST['submit'];
$insert=mysql_query("INSERT INTO comment (name,comment) VALUES ('$name','$comment') ");
echo "<meta HTTP-EQUIV='REFRESH' content='0; url=service.php'>";
}
else
{
echo "";
}
?>
<form class="comments" action="service.php" method="POST">
<h2>Name: </h2><br><input type="text" name="name" required/><br><br>
<h2>Comment:</h2><textarea name="comment" rows="10" cols="50" required></textarea><br><br><br>
<input type="submit" name="submit" value="Comment">
</form>
<?php
$getquery=mysql_query("SELECT * FROM comment ORDER BY id DESC");
while($rows=mysql_fetch_assoc($getquery))
{
$id=$rows['id'];
$date=$rows['date'];
$name=$rows['name'];
$comment=$rows['comment'];
echo '<h2><hr size="1"/><br><font color="green">' . $name . '</font><h2><br/>' . '<br/>' . $comment . '<br/><br><font color="red">' . $date. '</font><br/>' . '<hr size="1"/>'
;}
?>
</div>
<div class="copy">
<p class="w3-link">2014 </p>
Privacy & Policy
</div>
<div class="f_nav">
<ul>
<li>Skype</li>
<li>Linked in</li>
<li>Twitter</li>
<li>Facebook</li>
</ul>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
</body>
</html>
(ALL MY CODE ON THAT PAGE)
UPDATE:
The guys here will kill me, because now i am just edited your code, and not rewrite to mysqli or PDO, but as i saw, you stuck, so i've just updated, bacause i do not want to confuse with that too. I do some modifications, check my comments about that. (Moved the block of insertion to the top of file, add an error message, remove unnecesarry variables, rename the rows variable to row, etc...)
<?php
session_start();
include "../includes/config.php";
include "function.php";
include ('../includes/header.php');
//Set an empty errorMsg because later we will check it.
$errorMsg = '';
//If everything is set, or the SESSION["sess_user"] not empty.
//I moved this whole thing here, because if there are no output, we can
//redirect user from PHP, and do not need to use META REFREHS...
if (isset($_POST['submit']) && !empty($_POST['comment']) && (!empty($_POST["name"]) || !empty($_SESSION["sess_user"]))) {
if (!empty($_SESSION["sess_user"])) {
$name = $_SESSION["sess_user"];
} else {
$name = $_POST["name"];
}
//$comment = $_POST['comment']; //Use $_POST["comment"] directly
//$submit = $_POST['submit']; //Do not use it anywhere
$insert = mysql_query("INSERT INTO comment (name,comment) VALUES ('" . mysql_real_escape_string($name) . "','" . mysql_real_escape_string($_POST["comment"]) . "')");
Header("Location: service.php");
} else {
$errorMsg = "You need to fill all the fields.";
}
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Honda</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<link href='http://fonts.googleapis.com/css?family=Julius+Sans+One' rel='stylesheet' type='text/css'>
<link href="../css/style.css" rel="stylesheet" type="text/css" media="all" />
<!--start lightbox -->
<link rel="stylesheet" type="text/css" href="../css/jquery.lightbox.css">
<script src="../js/jquery.min.js"></script>
<script src="../js/jquery.lightbox.js"></script>
<script>
// Initiate Lightbox
$(function() {
$('.gallery1 a').lightbox();
});
</script>
</head>
<body>
<!--start header-->
<div class="h_bg">
<div class="wrap">
<div class="wrapper">
<div class="header">
<div class="logo">
<img src="../images/logo.png">
</div>
<div class="cssmenu">
<ul>
<li><span>Home</span></li>
<li><span>About</span></li>
<li class="active" class="has-sub"><span>Gallery</span>
</li>
<li class="last"><span>Contact</span></li>
<div class="clear"></div>
<form action="search.php" method="GET">
<div class="search">
<h2>search</h2>
<form>
<input type="text" name="query" placeholder="Enter Your search..." />
<input type="submit" value="">
</form>
</div>
</form>
<div class="search1">
<form action="" method="POST">
<br>
<h2>Welcome, <?= $_SESSION['sess_user']; ?>!</h2><br><br>
<div class="pw">
<h3>Change details</h3>
</div>
<br><br>
<h2>Logout</h2>
</form>
</div>
</div>
</ul>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<!-- start content -->
<div class="content_bg">
<div class="wrap">
<div class="wrapper">
<div class="main">
<div class="ser-main">
<h2 class="style">Gallery of honda</h2>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic1.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic2.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic3.jpg" alt="">
</div>
</div>
<div class="ser-grid-list img_style">
<div class="gallery1">
<img src="../images/ser_pic4.jpg" alt="">
</div>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
<div class="footer_bg">
<div class="wrap">
<div class="wrapper">
<div class="footer">
<div class="search69">
<?php
//Added here the errorMsg
if (!empty($errorMsg)) {
?>
<div class="error"><?php echo $errorMsg; ?></div>
<?php
}
?>
<form class="comments" action="service.php" method="POST">
<?php
if (!empty($_SESSION['sess_user'])) {
//If user logged in, use the name of it
?>
<h2>Name: </h2><br><?php echo $_SESSION['sess_user']; ?>
<br><br>
<?php
} else {
//Else, ask it
?>
<h2>Name: </h2><br><input type="text" name="name" required/><br><br>
<?php
}
?>
<h2>Comment:</h2><textarea name="comment" rows="10" cols="50" required></textarea><br><br><br>
<input type="submit" name="submit" value="Comment">
</form>
<?php
$getquery = mysql_query("SELECT * FROM comment ORDER BY id DESC");
//This is one row, not rows
while ($row = mysql_fetch_assoc($getquery)) {
/*
* These are not necessary
$id = $rows['id'];
$date = $rows['date'];
$name = $rows['name'];
$comment = $rows['comment'];
*/
echo '<h2><hr size="1"/><br><font color="green">' . $row['name'] . '</font><h2><br/>' . '<br/>' . $row['comment'] . '<br/><br><font color="red">' . $row['date'] . '</font><br/>' . '<hr size="1"/>'
;
}
?>
</div>
<div class="copy">
<p class="w3-link">2014 </p>
Privacy & Policy
</div>
<div class="f_nav">
<ul>
<li>Skype</li>
<li>Linked in</li>
<li>Twitter</li>
<li>Facebook</li>
</ul>
</div>
<div class="clear"></div>
</div>
</div>
</div>
</div>
</body>
</html>
NOTE: Do not use mysql functions since they are deprecated. use mysqli or PDO functions instead.
Acoid for sql injections, so escape your data!
If i got it well, you want the form to automatically gets the name of a logged user. You should:
<?php $username = isset($_SESSION['sess_user']) ? $_SESSION['sess_user'] : "";?>
To store the username or "" into $username, depending on whether user is authentified or not. Then in your input line within the form:
<h2>Name: </h2><br><input type="text" name="name" value="<?php echo $username; ?>" required/><br><br>

Few problems at the same time, PHP

I'm working on one website but i'm confused.
<?php
ob_start("ob_gzhandler");
session_start();
define('FORUM_ROOT', 'forum/');
require FORUM_ROOT.'include/common.php';
// Where will we go after login?
$forum_page['redirect_url'] = 'http://l2topsites.net/';
$forum_page['form_action'] = forum_link($forum_url['login']);
$forum_page['hidden_fields'] = array(
'form_sent' => '<input type="hidden" name="form_sent" value="1" />',
'redirect_url' => '<input type="hidden" name="redirect_url" value="'.forum_htmlencode($forum_page['redirect_url']).'" />',
'csrf_token' => '<input type="hidden" name="csrf_token" value="'.generate_form_token($forum_page['form_action']).'" />'
);
include "conf.php";
$opala = $_GET['p'];
if (isset($opala)) {
$page = '_data/'.$opala.'.php';
} else {
$page = "_data/indexa.php";
}
if (!is_file($page)) {
echo 'This page not found!';
} else {
include "_data/".basename($page) ;
}
$sredata = ob_get_clean();
if(!isset($title)) $title = "[L2TopSites] - Top Lineage 2 Ranking Sites";
$online = mysql_fetch_assoc(mysql_query("SELECT SQL_CACHE COUNT(user_id) FROM `foo_online`"));
$online = $online['COUNT(user_id)'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<title><? echo $title; ?></title>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<meta http-equiv="content-language" content="bg" />
<base href="http://l2topsites.net" />
<meta name="robots" content="all,follow" />
<meta name="google-site-verification" content="0G89ZsSF30caf4PJk17uLLtejlwnl8oO2mUN4ywZCw8" />
<meta name="description" content="Top Lineage2 Server only on TopZone.eu" />
<meta name="keywords" content="topzone, lineage2, servers, rank, votes, top10, top25, top100, lineage2 servers" />
<meta http-equiv="Cache-Control" content="max-age=3600" />
<link type="text/css" rel="stylesheet" href="/min/f=style.css" />
</head>
<body>
<div id="content">
<div id="maintop"></div>
<div id="main">
<div id="header">
<div id="lpanel">
<?
if (!$forum_user['is_guest'])
{
echo "<div class=\"usermenu\">";
echo "<img src=\"images/button1.png\" width=\"90\" height=\"23\" alt=\"\" /><br />";
echo "<img src=\"images/button2.png\" width=\"90\" height=\"23\" alt=\"\" /><br />";
echo "<img src=\"images/button3.png\" width=\"90\" height=\"23\" alt=\"\" />";
echo "</div><div id=\"ltext\" style=\"padding-top: 5px;\">";
echo "Logged in as: ".$forum_user['username']."";
if($forum_user['is_admmod']==1){
echo " | Admin Panel";
}
echo "</div>";
}
else
{
?>
<form action="<?php echo $forum_page['form_action'] ?>" method="post">
<?php echo implode("\n\t\t", $forum_page['hidden_fields'])."\n" ?>
<table border="0">
<tr><td width="10"><img class="img" src="images/user.png" width="17" height="19" alt="" /></td><td><input type="text" name="req_username" id="userinput" /></td></tr>
<tr><td width="10"><img class="img" src="images/pass.png" width="17" height="19" alt="" /></td><td><input type="password" name="req_password" id="passinput" /></td></tr>
</table>
<input type="submit" name="submit" value="" id="login" />
<img src="images/register.png" alt="" border="0" />
<div id="ltext">
Forget Password?
<input type="checkbox" id="input" name="save_pass" value="1" /><span>Remember me</span></div>
</form>
<? } ?>
</div>
</div>
<div id="mbaner1">
<div id="mb1l"></div>
<div id="mb1b">
<div id="mb1">
<img src="images/baner1.png" width="728" height="90" alt="" border="0" />
</div>
</div>
<div id="mb2r"></div>
</div>
<div id="left">
<div class="btop"></div>
<div class="mback">
<div id="box1t"></div>
<ul>
<li>Home</li>
<li>News</li>
<li>Contact</li>
</ul>
</div>
<div class="bbottom"></div>
<div class="btop"></div>
<div class="mback">
<div id="box2t"></div>
<ul>
<li>All Servers (by Vote)</li>
<li>All Servers (by Date)</li>
<li>Premium Servers</li>
<li>Search Server</li>
<li>Add Server</li>
</ul>
</div>
<div class="bbottom"></div>
<div class="btop"></div>
<div class="mback">
<div id="box3t"></div>
<ul>
<li>Crests</li>
<li>L2 Guides</li>
<li>Forum</li>
</ul>
</div>
<div class="bbottom"></div>
<div class="btop"></div>
<div id="aback">
<div id="box4t"></div>
<div id="adsense"><script type="text/javascript">
<!--
google_ad_client="pub-4584526598914996";google_ad_slot="3047263056";google_ad_width=121;google_ad_height=240;//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>
</div>
<div class="bbottom"></div>
</div>
<div id="mcontent">
<div id="glineage"></div>
<div id="mcontenttop"></div>
<div id="mcontentt">
<?php
echo $sredata;
$btemi = mysql_fetch_assoc(mysql_query("SELECT SQL_CACHE COUNT(id) FROM foo_topics"));
$broitemi = $btemi['COUNT(id)'];
$bposts = mysql_fetch_assoc(mysql_query("SELECT SQL_CACHE COUNT(id) FROM foo_posts"));
$broipostove = $bposts['COUNT(id)'];
$bservers = mysql_fetch_assoc(mysql_query("SELECT SQL_CACHE COUNT(id) FROM s_servers WHERE `odobren` = '1'"));
$broiserveri = $bservers['COUNT(id)'];
?>
<div style="clear: both;"></div>
</div>
<div id="mcontentbottom"></div>
</div>
<div id="right">
<div id="fserver">
<?php
$q = mysql_fetch_assoc(mysql_query("SELECT SQL_CACHE `fname`, `fid` FROM `s_set`"));
echo "<b>".$q['fname']."</b>";
?>
</div>
<div class="btop"></div>
<div id="rback">
<div id="box5t"></div>
<ul>
<li>Gaming Forums</li>
<li>Counter-Strike</li>
<li>MuOnline</li>
<li>Ragnarok Online</li>
<li>World Of Warcraft</li>
<li>OnlineGames</li>
<li>OnlineTop100</li>
</ul>
</div>
<div class="bbottom"></div>
<div class="btop"></div>
<div class="mback">
<div id="box6t"></div>
<ul>
<li>Your ip is: <?=$_SERVER['REMOTE_ADDR']?></li>
<li>Servers indexed: <?=$broiserveri?></li>
<li>Threads on forum: <?=$broitemi?></li>
<li>Posts on forum: <?=$broipostove?></li>
<li>Online users: <?=$online?></li>
</ul>
</div>
<div class="bbottom"></div>
<div class="btop"></div>
<div class="mback">
<div id="box7t"></div>
<ul>
<li>Tutorials</li>
<li>Links Direcotory</li>
<li>You link here?</li>
</ul>
</div>
<div class="bbottom"></div>
</div>
<div id="footer">
<div id="fooleft"></div>
<div id="foo">
<ul>
<li>Home | </li>
<li>ViewServers | </li>
<li>Register | </li>
<li>Crests | </li>
<li>Forum | </li>
<li>AddServer | </li>
<li>Contact | </li>
<li>Privacy Policy | </li>
<li>Terms and Conditions</li>
</ul>
<span id="tend">All right reserved L2Topsites © 2010-2011
L2Topsites.net is not responsable for any external content.
</div>
<div id="fooright"></div>
</div>
<div id="mainbottom"></div>
</div>
</div>
<script type="text/javascript" src="/min/f=javascript.js"></script>
<!-- NACHALO NA TYXO.BG BROYACH -->
<script type="text/javascript">
<!--
d=document;d.write('<a href="http://www.tyxo.bg/?87885" title="Tyxo.bg counter" target=" blank"><img width="1" height="1" border="0" alt="Tyxo.bg counter"');d.write(' src="http://cnt.tyxo.bg/87885?rnd='+Math.round(Math.random()*2147483647));d.write('&sp='+screen.width+'x'+screen.height+'&r='+escape(d.referrer)+'" /><\/a>');//-->
</script>
<noscript><img src="http://cnt.tyxo.bg/87885" width="1" height="1" border="0" alt="Tyxo.bg counter" /></noscript>
</body>
</html>
Error is
`Warning: ob_start(): output handler 'ob_gzhandler' conflicts with 'zlib output compression' in D:\xampp\htdocs\index.php on line 2
Notice: ob_start(): failed to create buffer in D:\xampp\htdocs\index.php on line 2`
I don't know if it is because of that but links are broken too.
Its like when I click somewhere it goes to
index.php/page
but its should go on
index.php?p=page

Categories