session variable is not passing to next page - php

index.php
<?php
session_start();
?>
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type"content="text/html;charset=UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery- .min.js"
type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
<link href="style1.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" media="screen and (max-width: 360px)" href="portrait.css">
<link rel="stylesheet" type="text/css" media="screen and (min-width: 361px) and (max-width: 480px)" href="landscape.css">
<link rel="stylesheet" type="text/css" media="screen and (min-width: 481px)" href="desktop.css">
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
rel="Stylesheet"type="text/css"/>
</head>
<body>
<div id="container">
<div id="banner">
</div>
<div class="clear"></div>
</br></br></br>
<br /><br /><br /><br />
<?php echo $reg; ?>
<form action="login.php" method="post" enctype="multipart/form-data">
<table border="2" align="center" width="400px" cellspacing="0" cellpadding="2" style="border-color:#FFF;">
<tr>
<td align="center" style="background:#4CAF50; font-weight:bold;" colspan="2">लॉगिन</td>
</tr>
<tr>
<td>यूजर का नाम: </td>
<td><input type="text" name="name" size="25"></td>
</tr>
<tr>
<td>पासवर्ड:</td>
<td><input type="password" name="password" size="25"></td>
</tr>
<tr>
<td align="center" colspan="2"><input type="Submit" value="submit"></td>
</tr>
</table>
</form>
</br></br></br></br></br></br></br></br></br>
</div>
</body>
</html>
2.login.php
<?php
session_start();
$name=$_REQUEST['name'];
$password=$_REQUEST['password'];
if($name=='admin' && $password=='admin')
{
session_start();
$_SESSION['sid']=session_id();
header('location:template.php');
}
else
{
header('location:index.php');
$_SESSION['reg']="<font color=#800000; size=4>Invalid User Name and Password. Please Enter Again.</font>";
}
?>
template.php
<meta http-equiv="Content-Type"content="text/html;charset=UTF-8">
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"
type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js" type="text/javascript"></script>
<link href="style1.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" type="text/css" media="screen and (max-width: 360px)" href="portrait.css">
<link rel="stylesheet" type="text/css" media="screen and (min-width: 361px) and (max-width: 480px)" href="landscape.css">
<link rel="stylesheet" type="text/css" media="screen and (min-width: 481px)" href="desktop.css">
<link href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/base/jquery-ui.css"
rel="Stylesheet"type="text/css"/>
</head>
<body>
<div id="container">
<div id="navbar">
<ul>
<li align="center">मुख पृष्ठ </li>
<li align="center">निविदा</li>
<li align="center">कार्य आदेश </li>
<li align="center">वेतन</li>
<li align="center">दुकान </li>
<li align="center">स्टॉक</li>
<li align="center">विविध</li>
<li align="center">लेखा-जोखा</li>
<li align="center">लोग आउट</li>
</ul>
</div>
<div class="clear"></div>
<div id="content">
<br/><br/><br/><br/>
<center><img src=images/looks-solid.jpg width=500 height=250 alt=Edit /></center>
</br> </br><br/><br/>
</div>
<div id="bottom"></div>
<div class="clear"></div>
<?php }
else
{
header("location:index.php");
}
?>
</div>
</body>
</html>
logout.php
session_start();
session_destroy();
setcookie(PHPSESSID,session_id(),time()-1);
header('location:index.php');
?>
My session is not working on online project, but on localhost,it is working correctly. I want after logout, on pressing back button it should not show the page,that it shows after login.

Related

how to fix php page keeps on loading?

I am creating a webapp for my company and one of my PHP pages keeps on
loading when I add another header.php into it, but another page is loading fine if I add this header.
my code: this section is added to the below page (view_enquiry.php)
head.php:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Tell the browser to be responsive to screen width -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<!-- Favicon icon -->
<link rel="icon" type="image/png" sizes="16x16" href="images/logo.png">
<?php
include('connect.php');
$sql_head_title = "select * from manage_website";
$result_head_title = $conn->query($sql_head_title);
$row_head_title = mysqli_fetch_array($result_head_title);
?>
<title><?php echo $row_head_title['title'];?></title>
<link href="css/lib/chartist/chartist.min.css" rel="stylesheet">
<link href="css/lib/owl.carousel.min.css" rel="stylesheet" />
<link href="css/lib/owl.theme.default.min.css" rel="stylesheet" />
<!-- Bootstrap Core CSS -->
<link href="css/lib/bootstrap/bootstrap.min.css" rel="stylesheet">
<!-- Custom CSS -->
<link href="css/helper.css" rel="stylesheet">
<link href="css/snackbar.css" rel="stylesheet">
<link href="css/modal.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<!-- HTML5 Shim and Respond.js IE8 support of HTML5 elements and media queries -->
<!-- WARNING: Respond.js doesn't work if you view the page via file:** -->
<!--[if lt IE 9]>
<script src="https:**oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
<script src="https:**oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" href="css/lib/html5-editor/bootstrap-wysihtml5.css" />
<link href="css/lib/calendar2/semantic.ui.min.css" rel="stylesheet">
<link href="css/lib/calendar2/pignose.calendar.min.css" rel="stylesheet">
</head>
<body class="fix-header fix-sidebar">
<!-- Preloader - style you can find in spinners.css -->
<div class="preloader">
<svg class="circular" viewBox="25 25 50 50">
<circle class="path" cx="50" cy="50" r="20" fill="none" stroke-width="2" stroke-miterlimit="10" /> </svg>
</div>
</body>
</html>
this is my page and this page keeps on loading (view_enquiry.php)
<?php include('head.php');?>
<?php include('header.php');?>
<?php include('sidebar.php');?>
<?php
include ('connect.php');
?>
<div class="content-wrapper" style="padding-top: 48px;">
<div class="container-fluid">
<div class="status" style="color:red;position: relative;top:215px;positin: relative;left:565px;position:absolute;">
<h4>Status Updated Successfully</h4>
</div>
<div class="row" col-sm color: #031aaf" style="padding-top: 12px;">
<div class="col-sm-3">
<h3 style="color: #828282"><b>Enquiry Details</b></h3>
</div>
<div class="col-sm-3">
<form action="" method="get" " >
<input name="search" type="text" placeholder="Search(Name/number)" size="20px">
<button type="submit" name="submit" value="search" class="button"><i class="fa fa-search"></i></button>
</form>
</div>
<div class="col-sm-5" style="text-align: left;">
<form action="between.php" method="GET" >
<input type="date" name="from" required> To
<input type="date" name="to" required>
<button type="submit" class="button"><i class="fa fa-search"></i></button>
</form>
</div>
</div>
<b><p style="text-align:right; color: #828282" > Yesterday's Enquiry Count :
<?php
$v="SELECT COUNT(id) FROM task WHERE (`date` = CURDATE() - INTERVAL 1 DAY)AND completed=0" ;
$s=mysqli_query($conn,$v);
$w=mysqli_fetch_assoc($s);
echo $w['COUNT(id)'] ;
?>
</b>
<br><br>
<table border="1px;" style="margin-top:-11px;color: #333333" bgcolor="#fcb983" >
<tr style="color: black">
<th></th>
<th>Name</th>
<th>Address</th>
<th>Enquiry Date</th>
<th>Category/Work</th>
<th>Followup Date</th>
<th>Mobile</th>
<th>Comment</th>
<th>Postponed To</th>
<th>Edit</th>
<th>Delete</th>
<th>Complete</th>
</tr>
<?php
if(#$_GET['search'] && #$_GET['search']!=''){
$query=$_GET['search'];
$query = htmlspecialchars($query);
$vari = mysqli_query($conn,"SELECT * FROM task WHERE completed=0 AND ((`task_name` LIKE '%".$query."%') OR (`mobile` LIKE '%".$query."%') OR (`address` LIKE '%".$query."%') OR (`work` LIKE '%".$query."%') OR (`command` LIKE '%".$query."%'))") or die(mysqli_error($con));
//$vari="SELECT * FROM task WHERE completed=0 AND (task_name='$s' OR mobile='$s')";
}
else{
$vari = mysqli_query($conn,"SELECT * FROM task WHERE (`date` = CURDATE() - INTERVAL 1 DAY) AND completed=0") or die(mysqli_error($conn));
//$vari="SELECT * FROM task WHERE completed=0";
}
//$variable=mysqli_query($con,$vari);
while ($row = mysqli_fetch_array($vari)){
?>
<tr>
<td><span class="glyphicon glyphicon-chevron-right"></span></td>
<td><?php echo $row["task_name"]; ?></td>
<td><?php echo $row["address"]; ?></td>
<td><?php echo date('d-m-Y',strtotime($row["date"])); ?></td>
<td><?php echo $row["work"];?></td>
<td><?php echo date('D - d-m-Y',strtotime($row["todo"])); ?></td>
<td><?php echo $row["mobile"] ;?></td>
<td><?php echo $row["command"];?></td>
<td></span></center></td>
<td></span></center></td>
<td><center><span class="fa fa-trash"></span></center></td>
<td><center><span class="fa fa-check-square"></span></center></td>
</tr>
<?php } ?>
</table>
</div>
</div>
Please help me this details

"Unexpected end of file" error in perfectly error-free PHP file with custom router.php

Currently I am using PHP's built in web server, and I recently started using a custom router script so that I can effectively implement a custom 404 page. Here is router.php:
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
chdir($root);
$path = '/'.ltrim(parse_url($_SERVER['REQUEST_URI'])['path'],'/');
set_include_path(get_include_path().':'.__DIR__);
if(file_exists($root.$path))
{
if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/')
$path = rtrim($path,'/').'/index.php';
if(strpos($path,'.php') === false) return false;
else {
chdir(dirname($root.$path));
require_once $root.$path;
}
}else include_once 'pages/404.php';
However, I have a login page that uses PHP to... login, of course. However, using this router.php, the login page gives me the usual "[website] cannot handle your request" and the logs say Unexpected end of file. The code worked just fine until now (and passes many syntax checkers), so I suspect either my router.php somehow isn't fit to run proper PHP files, or it's messing with how said files are handled.
Heres my login PHP:
<?php
$user = $_POST['username'];
$pass = $_POST['pass'];
$return = $_GET['return'];
if (!isset($_GET['return']))
{
echo "<span>No return page is selected to return to, please go back to the <a href='../'>Home page</a> and go to a different page.</span>";
}
if($user == "adminuser"
&& $pass == "adminpass")
{
include("../pages/" . $return . "/secret/secure.php");
}
else
{
if(isset($_POST))
{?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>Login V6</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!--===============================================================================================-->
<link rel="icon" type="image/png" href="images/favicon.ico"/>
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/bootstrap/css/bootstrap.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="fonts/font-awesome-4.7.0/css/font-awesome.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="fonts/iconic/css/material-design-iconic-font.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/animate/animate.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/css-hamburgers/hamburgers.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/animsition/css/animsition.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/select2/select2.min.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="vendor/daterangepicker/daterangepicker.css">
<!--===============================================================================================-->
<link rel="stylesheet" type="text/css" href="css/util.css">
<link rel="stylesheet" type="text/css" href="css/main.css">
<!--===============================================================================================-->
</head>
<body>
<div class="limiter">
<div class="container-login100">
<div class="wrap-login100 p-t-85 p-b-20">
<form class="login100-form validate-form" method="POST" action="index.php?monster=<?php echo $monster ?>">
<span class="login100-form-title p-b-70">
Welcome
</span>
<span class="login100-form-avatar">
<img src="images/logo.png" alt="AVATAR">
</span>
<input type="hidden" name="monster" value="<?php $_GET['monster'];?>">
<div class="wrap-input100 validate-input m-t-85 m-b-35" data-validate = "Enter username">
<input class="input100" type="text" name="username">
<span class="focus-input100" data-placeholder="Username"></span>
</div>
<div class="wrap-input100 validate-input m-b-50" data-validate="Enter password">
<input class="input100" type="password" name="pass">
<span class="focus-input100" data-placeholder="Password"></span>
</div>
<div class="container-login100-form-btn">
<input class="login100-form-btn" type="submit" name="submit" value="Login"></input>
</div>
<ul class="login-more p-t-190">
<li class="m-b-8">
<span class="txt1">
Forgot
</span>
<a href="../index.html#contact" class="txt2">
Username / Password?
</a>
</li>
</ul>
</form>
</div>
</div>
</div>
<div id="dropDownSelect1"></div>
<!--===============================================================================================-->
<script src="vendor/jquery/jquery-3.2.1.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/animsition/js/animsition.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/bootstrap/js/popper.js"></script>
<script src="vendor/bootstrap/js/bootstrap.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/select2/select2.min.js"></script>
<!--===============================================================================================-->
<script src="vendor/daterangepicker/moment.min.js"></script>
<script src="vendor/daterangepicker/daterangepicker.js"></script>
<!--===============================================================================================-->
<script src="vendor/countdowntime/countdowntime.js"></script>
<!--===============================================================================================-->
<script src="js/main.js"></script>
</body>
</html>
<?}
}
?>
I know next to nothing about the science behind PHP routers (and I got mine from a stackoverflow answer), so if something in my router.php is painfully wrong, well, that's why :/
Try to add php to <? in Your login.php:
</body>
</html>
<?}<- this one
}
?>

move a table entry to another table

I have a quote table that people insert basic information, such as name, product type etc. Which is all fine.
The admin can see the quote table and has a button to view the information in a structured manner.
Now what i have been trying to do is add a button called "Accept" and "Deny" which would move the table entry to the Denied or accepted table (same structure as the quote table)
I have looked around on google but only found assistance in making a button to delete entries or add new entries.
Below is the admin quote viewing page code with the view button:
<?php
session_start();
include("dbconnection.php");
include("checklogin.php");
check_login();
?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html;charset=UTF-8" />
<meta charset="utf-8" />
<title>Admin | Manage Logged Claims</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta content="" name="description" />
<meta content="" name="author" />
<link href="assets/plugins/bootstrap-select2/select2.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/plugins/jquery-datatable/css/jquery.dataTables.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/datatables-responsive/css/datatables.responsive.css"
rel="stylesheet" type="text/css" media="screen"/>
<link href="assets/plugins/boostrapv3/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/boostrapv3/css/bootstrap-theme.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/animate.min.css" rel="stylesheet" type="text/css"/>
<link href="assets/plugins/jquery-scrollbar/jquery.scrollbar.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/style.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/responsive.css" rel="stylesheet" type="text/css"/>
<link href="assets/css/custom-icon-set.css" rel="stylesheet" type="text/css"/>
</head>
<body class="">
<?php include("header.php");?>
<div class="page-container row">
<?php include("leftbar.php");?>
<div class="clearfix"></div>
<!-- END SIDEBAR MENU -->
</div>
</div>
<div class="page-content">
<!-- BEGIN SAMPLE PORTLET CONFIGURATION MODAL FORM-->
<div id="portlet-config" class="modal hide">
<div class="modal-header">
<button data-dismiss="modal" class="close" type="button"></button>
<h3>Widget Settings</h3>
</div>
<div class="modal-body"> Widget settings form goes here </div>
</div>
<div class="clearfix"></div>
<div class="content">
<ul class="breadcrumb">
<li>
<p>YOU ARE HERE</p>
</li>
<li>Claims Logged </li>
</ul>
<div class="page-title"> <i class="icon-custom-left"></i>
<h3>Manage Logged Claims</h3>
</div>
<div class="row-fluid">
<div class="span12">
<div class="grid simple ">
<div class="grid-title">
<h4>Table <span class="semi-bold">Styles</span></h4>
<div class="tools">
<a href="javascript:;" class="remove">
</a> </div>
</div>
<div class="grid-body ">
<table class="table table-hover table-condensed" id="example">
<thead>
<tr>
<th style="width:1%">#</th>
<th style="width:10%">Name</th>
<th style="width:10%" data-hide="phone,tablet">Email</th>
<th style="width:10%">Contact no</th>
<th style="width:20%" data-hide="phone,tablet">Claim Requested</th>
<th style="width:10%">Action </th>
</tr>
</thead>
<tbody>
<?php $ret=mysql_query("select * from prequest order by id desc");
$cnt=1;
while($row=mysql_fetch_array($ret))
{?>
<tr >
<td class="v-align-middle"><?php echo $cnt;?></td>
<td class="v-align-middle"><?php echo $row['name'];?></td>
<td class="v-align-middle"><span class="muted"><?php echo $row['email'];?></span></td>
<td><span class="muted"><?php echo $row['contactno'];?>
</span></td>
<td class="v-align-middle"><?php echo $row['wdd'];?>
<?php echo $row['cms'];?>
<?php echo $row['seo'];?>
<?php echo $row['smo'];?>
<?php echo $row['swd'];?>
<?php echo $row['dwd'];?>
<?php echo $row['fwd'];?>
<?php echo $row['dr'];?>
<?php echo $row['whs'];?>
<?php echo $row['wm'];?>
<?php echo $row['ed'];?>
<?php echo $row['wta'];?>
<?php echo $row['opi'];?>
<?php echo $row['ld'];?>
<?php echo $row['da'];?>
<?php echo $row['osc'];?>
<?php echo $row['nd'];?>
<?php echo $row['others'];?>
</td>
<td><button class="btn-danger-dark">View</button></td> <--VIEW BUTTON
</tr>
<?php $cnt=$cnt+1; } ?>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
<div class="addNewRow"></div>
</div>
</div>
<script src="assets/plugins/jquery-1.8.3.min.js" type="text/javascript">
</script>
<script src="assets/plugins/jquery-ui/jquery-ui-1.10.1.custom.min.js" type="text/javascript"></script>
<script src="assets/plugins/boostrapv3/js/bootstrap.min.js" type="text/javascript"></script>
<script src="assets/plugins/breakpoints.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-unveil/jquery.unveil.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-scrollbar/jquery.scrollbar.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-block-ui/jqueryblockui.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-numberAnimate/jquery.animateNumbers.js" type="text/javascript"></script>
<script src="assets/plugins/bootstrap-select2/select2.min.js" type="text/javascript"></script>
<script src="assets/plugins/jquery-datatable/js/jquery.dataTables.min.js" type="text/javascript" ></script>
<script src="assets/plugins/jquery-datatable/extra/js/dataTables.tableTools.min.js" type="text/javascript" >
</script>
<script type="text/javascript" src="assets/plugins/datatables-responsive/js/datatables.responsive.js"></script>
<script type="text/javascript" src="assets/plugins/datatables-responsive/js/lodash.min.js"></script>
<script src="assets/js/datatables.js" type="text/javascript"></script>
<script src="assets/js/core.js" type="text/javascript"></script>
<script src="assets/js/chat.js" type="text/javascript"></script>
<script src="assets/js/demo.js" type="text/javascript"></script>
</body>
</html>
Have you considered a different approach?
If the two tables have the exact same structure, then all you need is a single table and add a column called 'accepted' and use 1 and 0 values to act as true and false.
Then you can search this single table WHERE 'accepted' = 1 for accepted entries, or 0 for denied entries. And to change an entry's status, simply update a single column. Much easier.
Example:
$result = mysqli_query("SELECT * FROM tableName WHERE accepted = 1");
That will get only entries you have marked as accepted.
Change it to WHERE accepted = 0" to get the denied entries.
And here is how you can allow the admin to change an entry's accepted/denied status easily:
$update = mysqli_query("UPDATE tableName SET accepted = 1 WHERE id = 12345");
By the way, I suggest you use mysqli instead of mysql, heres a good answer why.

Display products from database in php

I want to display product details in php page that is stored in mysql database.
my php page is as follows:
<?phpinclude 'databaseconfile.php';
$sql = "select * from book";
$result = mysql_query($sql);
?>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<title>Shop | ShareMyBook</title>
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/font-awesome.min.css" rel="stylesheet">
<link href="css/prettyPhoto.css" rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<link href="css/main.css" rel="stylesheet">
<link href="css/responsive.css" rel="stylesheet">
<link rel="shortcut icon" href="images/ico/favicon.ico">
<link rel="apple-touch-icon-precomposed" sizes="144x144" href="images/ico/apple-touch-icon-144-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="114x114" href="images/ico/apple-touch-icon-114-precomposed.png">
<link rel="apple-touch-icon-precomposed" sizes="72x72" href="images/ico/apple-touch-icon-72-precomposed.png">
<link rel="apple-touch-icon-precomposed" href="images/ico/apple-touch- icon-57-precomposed.png">
</head>
<body>
<div class="col-sm-4">
<div class="product-image-wrapper">
<div class="single-products">
<div class="productinfo text-center">
<?phpwhile ($row = mysql_fetch_array($result))
{?>
<img src="images/home/" alt="" />
<h2><?php echo $row['Book_Name']; ?></h2>
<p>Book 10</p>
<?php}?>
</div>
<div class="product-overlay">
<div class="overlay-content">
<h2>Price</h2>
<p>Book 10</p>
<i class="glyphicon glyphicon-eye-open"></i>view Book
</div>
</div>
</div>
<div class="choose">
<ul class="nav nav-pills nav-justified">
<li><i class="fa fa-plus-square"></i>Add to wishlist</li>
<li><i class="fa fa-shopping-cart"></i>Add to cart</li>
</ul>
</div>
</div>
</div>
</body>
</html>
when I try to run this page it says-Notice:Undefined variable:row on line 32, when it is already defined.
The mistake is the space required between php and while loop. I already told you in comment. Replace this chunk of code:
Replace first line with:
<?php include 'databaseconfile.php';
and :
<div class="productinfo text-center">
<?php while ($row = mysql_fetch_array($result))
{?>
<img src="images/home/" alt="" />
<h2><?php echo $row['Book_Name']; ?></h2>
<p>Book 10</p>
<?php}?>
</div>
The mistake is in first line.<?phpinclude 'databaseconfile.php';
You have to give space between php tag and include like this <?php include 'databaseconfile.php';

Pie chart in jQuery Mobile not showing up

I develop a jQuery mobile site and want to display pie chart, the data fetch form database to show in pie chart. Since the jQuery mobile link to another page using div, I make one div in index.php to display data from database, then when the data is showing up, I can view the data by click on the view link. At this part, I make jQuery load to load page piechart.php when click on the view link. The piechart.php page success called by jQuery load, but pie chart not appear, BUT if I right click on page and click view inspect element, it starts showing up normally the pie chart.
Why do I need to right click to display it??
This is index.php
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>SSPIC</title>
<meta name="viewport" content="width=device-width, maximum-scale=1.0, minimum-scale=1.0, initial-scale=1" />
<meta name="description" content="This site was created from a template originally designed and developed by Codify Design Studio. Find more free templates at http://www.adobe.com/devnet/author_bios/chris_converse.html" />
<link href="jquery-mobile/jquery.mobile.structure-1.0.min.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/formcalculations.js"></script>
<link href="styles/cakeform.css" rel="stylesheet" type="text/css" />
<script src="jquery-mobile/jquery-1.6.4.min.js" type="text/javascript"></script>
<script src="jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="themes/my_company.min.css" />
<link rel="stylesheet" href="includes/overrides.css" />
<script type="text/javascript" src="includes/custom.js"></script>
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script>
<link href="stylesheets/app.css" media="screen, projector, print" rel="stylesheet" type="text/css" />
<link href="stylesheets/pizza.css" media="screen, projector, print" rel="stylesheet" type="text/css" />
<script src="javascripts/vendor/snap.svg.js"></script>
<script src="javascripts/pizza.js"></script>
<script type="text/javascript">
function MM_popupMsg(msg) { //v1.0
alert(msg);
}
</script>
</head>
<body onload='hideTotal()'>
<div data-role="page" id="home" data-theme="a">
<div data-role="header">
<h1>Homepage</h1>
</div>
<div data-role="content">
<ul data-role="listview">
<li class="btn_a">About Us</li>
<li class="btn_s">Services</li>
<li class="btn_l">Search</li>
<li class="btn_c">Upload</li>
<li class="btn_c">Chart</li>
</ul>
</div>
<div data-role="">
</div>
</div>
<div data-role="page" id="locations" data-title="Find a Locations">
<div data-role="header">
<h1>Search Data</h1>
back
</div>
<div data-role="content">
<p></p>
<h2>Search Data</h2>
</div>
<div data-role="footer">
<div data-role="controlgroup" data-type="horizontal">
Home
</div>
<h4>©2013 SSPIC</h4>
</div>
</div>
<div data-role="page" id="contact_us" data-title="Contact Us">
<div data-role="header">
<h1>Upload</h1>
back
</div>
<div data-role="content" class="content_container">
<p><form action="insertimage.php" method="post" enctype="multipart/form-data" name="form1">
<h2 align="center"> </h2>
<h2 align="center">Information</h2>
<table width="63%" border="1" align="center">
<tr>
<td width="40%">Upload File</td>
<td width="60%"><input name="pic" type="file" id="pic" /></td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Submit" />
</div></td>
</tr>
</table>
<p align="center"> </p>
<p align="center"> </p>
<p align="center">
</form></p>
</div>
<div data-role="footer">
<div data-role="controlgroup" data-type="horizontal">
Home
</div>
<h4>©2013 SSPIC</h4>
</div>
</div>
<div data-role="page" id="chart" data-title="chart Us" class="chart">
<div data-role="header">
<h1>Pie Chart</h1>
back
</div>
<div id="output" data-role="content" class="content_container"></div>
<div data-role="content" class="content_container" id="k_chart">
<p>
<form action="insertimage.php" method="post" enctype="multipart/form-data" name="form1">
<h2 align="center"> </h2>
<h2 align="center">Display File</h2>
<table width="63%" border="1" align="center" class="table_chart">
<tr>
<td width="40%">Bil</td>
<td width="60%">Pusat rawatan</td>
<td width="60%">Pengasas</td>
<td width="60%">Bil pengamal</td>
<td width="60%">Total</td>
<td width="60%">Phone number</td>
<td width="60%">Peratus</td>
<td width="60%">view chart</td>
</tr>
<?php
include("connection.php");
$sel = mysql_query("select * from info");
$a = 1;
while($get_sel = mysql_fetch_array($sel))
{
?>
<tr>
<td width="40%"><?php echo $a++;?></td>
<td width="60%"><?php echo $get_sel['nama_PusatRawatan'];?></td>
<td width="40%"><?php echo $get_sel['nama_Pengasas'];?></td>
<td width="60%"><?php echo $get_sel['bilangan_Pengamal'];?></td>
<td width="40%"><?php echo $get_sel['totalPrice'];?></td>
<td width="60%"><?php echo $get_sel['phonenumber'];?></td>
<td width="60%"><?php echo $get_sel['peratus'];?></td>
<td width="60%"><div class="id"><?php echo $get_sel['id'];?></div><span class="viewBtn">View</span></td>
</tr>
<?php
}
?>
</table>
<p align="center"> </p>
<p align="center"> </p>
<p align="center">
</form></p>
</div>
<div data-role="footer">
<div data-role="controlgroup" data-type="horizontal">
Home
</div>
<h4>©2013 SSPIC</h4>
</div>
</div>
<script>
$(document).ready(function(e) {
// Pizza.init();
$('.viewBtn').on('click',function()
{
var id = $(this).closest('td').find('.id').text();
$('#k_chart').hide();
$('#output').load("piechart.php?id="+id);//load page to display pie chart
});
$(window).load(function() {
Pizza.init({
donut: false, // enable donut chart
donut_inner_ratio: 0.4, // between 0 and 1
percent_offset: 35, // relative to radius
stroke_color: '#333',
stroke_width: 0,
show_percent: true, // show or hide the percentage on the chart.
animation_speed: 500,
animation_type: 'elastic' // options: backin, backout, bounce, easein, easeinout, easeout, linear
});
});
});
</script>
</body>
</html>
This one is piechart.php
<link href="jquery-mobile/jquery.mobile.structure-1.0.min.css" rel="stylesheet" type="text/css" />
<script src="jquery-mobile/jquery.mobile-1.0.min.js" type="text/javascript"></script>
<link rel="stylesheet" href="themes/my_company.min.css" />
<link rel="stylesheet" href="includes/overrides.css" />
<link href="stylesheets/app.css" media="screen, projector, print" rel="stylesheet" type="text/css" />
<link href="stylesheets/pizza.css" media="screen, projector, print" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery-1.7.1.min.js"></script><script src="javascripts/vendor/snap.svg.js"></script>
<script src="javascripts/pizza.js"></script>
<div data-role="content" class="content_container">
<p>
<div id="jquery-script-menu">
<div class="jquery-script-center">
<div class="jquery-script-clear"></div>
</div>
</div>
<h1 style="margin-top:150px;" align="center">Papar peratus lulus pie chart </h1>
<div class="row">
<div class="large-12 columns">
<h3>Graphs</h3>
</div>
</div>
<?php
include("connection.php");
$id_info = $_GET['id'];
$papar = mysql_query("select *from info where id = '$id_info'");
$get_papar = mysql_fetch_array($papar);
if($get_papar['peratus']>0 and $get_papar['peratus']<=50)
{
$xlulus = $get_papar['peratus'];
$lulus = 100 - $xlulus;
}
else
{
$lulus = $get_papar['peratus'];
$xlulus = 100 - $lulus;
}
?>
<div class="row">
<div class="large-4 small-4 columns">
<ul data-pie-id="svg">
<li data-value="<?php echo $xlulus;?>">Tidak memenuhi syarat</li><li data-value="<?php echo $lulus;?>">Memenuhi syarat</li>
</ul>
</div>
<div class="large-8 small-8 columns">
<div id="svg"></div>
</div>
</div>
</p>
</div>
The jQuery code is at the bottom of page index.php..
You need to correctly time your plugin initialization.
First forget about document ready and window load, they will not work correctly with jQuery Mobile application (usually they trigger before jQuery Mobile content is successfully enhanced).
Instead you should learn how to use jQuery Mobile page events, for example pageinit event exists to replace document ready.
Read more about it here.
Now regarding your main problem, your plugin must be initialized during the pageshow event. A lot of visual plugins (carousels, charts ..) require correct page height. When working with jQuery Mobile page height is correctly calculated only during pageshow event, it will be 0 in any other case.
Page event initialization order can be found here.

Categories