|
|
|
รบกวนช่วยดูให้หน่อยนะครับ เวลาส่งตัวแปร Session เหมือนกับมันหลุดเลยอ่ะครับ |
|
|
|
|
|
|
|
เวลาส่งตัวแปร Session เหมือนกับมันหลุดเลยอ่ะครับ
คือเวลาสั่งซื้อของเสร็จเรียบร้อยแล้ว login มันจะหลุดอ่ะครับ
ตามรูปเลยครับ
Product.php
<?
session_start();
ob_start();
include "connect.php";
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>สินค้า</title>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.register {
font-size: 12px;
}
.footer {
font-size: 14px;
font-weight: bold;
}
body {
background-image: url(Image/BG.gif);
}
</style>
<script language="javascript">
function check(){
if(document.Login.username.value==""){
alert('กรุณา Login');
document.Login.username.focus();
return false;
}
return true;
}
</script>
</head>
<body>
<div align="center">
<table width="1000" height="250" border="0">
<tr>
<td><img src="Image/Header.jpg" width="1000" height="250" /></td>
</tr>
</table>
</div>
<div align="center">
<table width="1000" border="0">
<tr>
<td><ul id="MenuBar1" class="MenuBarHorizontal">
<li><a href="Index.php">หน้าแรก</a> </li>
<li><a href="Product.php" class="MenuBarItemSubmenu">สินค้า</a>
<ul>
<?
$sql_producttype = "select * from producttype";
$result_producttype = mysql_query($sql_producttype);
while($query_producttype = mysql_fetch_array($result_producttype)){
?>
<li><a href="Product.php?producttype=<?=$query_producttype["producttype_id"];?>"><?=$query_producttype["producttype_name"];?></a></li>
<?
}
?>
</ul>
</li>
<li><a href="Consignment.php">ฝากขายสินค้า</a></li>
<li><a href="News.php">ข่าวสาร</a></li>
<li><a href="Webboard.php">เว็บบอร์ด</a></li>
</ul></td>
</tr>
</table>
</div>
<div align="center">
<table width="1000" border="0">
<tr>
<td width="250" align="center" valign="top">
<?
if(($_SESSION['member_id'] == "") || ($_SESSION['status'] != "USER")){
?>
<form id="Login" name="Login" method="post" action="check_login.php">
<table width="250" border="0">
<tr>
<td colspan="2" align="left" valign="middle">Login</td>
</tr>
<tr>
<td width="80" align="left" valign="middle">Username :</td>
<td width="159" align="left" valign="middle"><label for="username"></label>
<input type="text" name="username" id="username" /></td>
</tr>
<tr>
<td align="left" valign="middle">Password :</td>
<td align="left" valign="middle"><label for="password"></label>
<input type="password" name="password" id="password" /></td>
</tr>
<tr>
<td align="left" valign="middle"> </td>
<td align="left" valign="middle"><?=$_SESSION['member_id'];?></td>
</tr>
<tr>
<td align="center" valign="middle" class="register"><a href="Register.php">สมัครสมาชิก</a></td>
<td align="left" valign="middle"><input type="submit" name="button" id="button" value="Login" /></td>
</tr>
</table>
</form>
<?
}else{
$sql_member = "select * from member where member_id = '".$_SESSION['member_id']."' ";
$result_member = mysql_query($sql_member);
$query_member = mysql_fetch_array($result_member);
?>
<form id="Login" name="Login" method="post" action="logout.php">
<table width="250" border="0">
<tr>
<td colspan="2" align="left" valign="middle">สวัสดี</td>
</tr>
<tr>
<td width="80" align="left" valign="middle">คุณ :</td>
<td width="159" align="left" valign="middle"><?=$query_member["username"];?></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" class="register"><a href="EditUser.php">แก้ไขข้อมูลส่วนตัว</a></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" class="register"><a href="ConsignmentUser.php">สินค้าฝากขาย</a></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" class="register"><a href="Returns.php">คืนสินค้า</a></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" class="register"><a href="Status.php">สถานะการสั่งซื้อสินค้า</a></td>
</tr>
<tr>
<td align="center" valign="middle" class="register"> </td>
<td align="left" valign="middle"><input type="submit" name="button" id="button" value="Logout" /></td>
</tr>
</table>
</form>
<?
}
?>
</td>
<td width="750" align="center" valign="top">
<form id="product" name="product" method="post" action="product.php">
<table width="750" border="0">
<tr>
<td colspan="4" align="right" valign="middle"><input type="text" name="Search" id="Search" />
<input type="submit" name="button2" id="button2" value="ค้นหา" /></td>
</tr>
<?
$protype = $_GET['producttype'];
$txtSearch = $_POST["Search"];
$page = $_GET['page'];
if($protype != ""){
$sql_product = "select *
from product,producttype,member
where product.product_type = '$protype'
and producttype.producttype_id = '$protype'
and product.member_id = member.member_id
and member.status = 'ADMIN'";
}else if($txtSearch != ""){
$sql_product = "select *
from product,producttype,member
where product.product_type = producttype.producttype_id
and product.member_id = member.member_id
and member.status = 'ADMIN'
and product_brand like '%$txtSearch%'";
}else{
if($page==""){
$page=1;
}
$sql = "select *
from product,member
where product.member_id = member.member_id
and member.status = 'ADMIN'";
$result = mysql_query($sql);
$totals = mysql_num_rows($result);
$each=10;
$totalpages = ceil($totals/$each);
$goto = ($page-1)*$each;
$sql_product = "select *
from product,producttype,member
where product.product_type = producttype.producttype_id
and product.member_id = member.member_id
and member.status = 'ADMIN'
limit $goto,$each";
}
$result_product = mysql_query($sql_product);
$num_row = mysql_num_rows($result_product);
if($num_row == 0){
?>
<tr>
<td height="21" colspan="4" align="center" valign="middle"></td>
</tr>
<tr>
<td height="21" colspan="4" align="center" valign="middle"></td>
</tr>
<tr>
<td height="21" colspan="4" align="center" valign="middle"></td>
</tr>
<tr>
<td height="21" colspan="4" align="center" valign="middle"></td>
</tr>
<tr>
<td height="21" colspan="4" align="center" valign="middle">ไม่พบรายการสินค้า</td>
</tr>
<tr>
<td height="21" colspan="4" align="center" valign="middle"></td>
</tr>
<tr>
<td height="21" colspan="4" align="center" valign="middle"></td>
</tr>
<tr>
<td height="21" colspan="4" align="center" valign="middle"></td>
</tr>
<?
}else{
?>
<tr>
<td width="70" align="center" valign="middle">รหัส</td>
<td width="120" align="center" valign="middle">รูป</td>
<td width="382" align="center" valign="middle">ราคา</td>
<td width="160" align="center" valign="middle"> </td>
</tr>
<?
while($query_product = mysql_fetch_array($result_product)){
?>
<tr>
<td rowspan="2" align="center" valign="middle"><?=$query_product["product_id"];?></td>
<td rowspan="2" align="center" valign="middle"><img src="Product/<?=$query_product["product_image"];?>" width="100" height="100"/></td>
<td rowspan="2" align="center" valign="middle">
ประเภท : <?=$query_product["producttype_name"];?><br />
ยี่ห้อ : <?=$query_product["product_brand"];?><br />
ราคา : <?=$query_product["product_price"];?> ฿
</td>
<td height="21" align="center" valign="middle"><a href="ProductDetail.php?proid=<?=$query_product["product_id"];?>" target="_blank">รายละเอียด</a></td>
</tr>
<tr>
<td align="center" valign="top" onclick="return check()"><a href="Basket.php?proid=<?=$query_product["product_id"];?>">หยิบลงตระกร้า</a></td>
</tr>
<?
}
}
?>
<tr>
<td colspan="4" align="center" valign="middle"> </td>
</tr>
<tr>
<td colspan="4" align="center" valign="middle">
<?
if($protype != ""){
echo "มีทั้งหมด $num_row รายการ";
}else if($txtSearch != ""){
echo "มีทั้งหมด $num_row รายการ";
}else{
echo "มีทั้งหมด $totals รายการ : ";
if($totalpages>1){
for($i=1;$i<=$totalpages;$i++){
if($i==$page){
echo"<b>หน้า $page</b>";
}else{
echo" | <a href=\"Product.php?page=$i\">$i</a> ";
}
}
}
}
?>
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</div>
<div align="center">
<table width="1000" border="0">
<tr>
<td align="center" valign="middle"><br />
<span class="footer">Copyright © 2014 All rights reserved. Do not duplicate or redistribute in any form prior permission.</span><br />
<br /></td>
</tr>
</table>
</div>
<script type="text/javascript">
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
</script>
</body>
</html>
<?
include "closeDb.php";
?>
Basket.php
<?
session_start();
ob_start();
include "connect.php";
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>สั่งซื้อสินค้า</title>
</head>
<body>
<?
$proid = $_GET[proid];
session_register(sess_productid);
session_register(sess_productbrand);
session_register(sess_productprice);
session_register(sess_productqty);
if(count($sess_productid) == 0 ){
$check = 1;
}else if(!in_array($proid,$sess_productid)){ //ถ้่าไม่มีรหัสสินค้าอยู่ใน array ของ sess_id เช็คว่าเลือกมาซ้ำรึป่าว กรณี นี้ไม่ซ้ำ
$check = 1;
}else{
echo "<script>alert('สินค้าที่เลืิอกซ้ำ')</script>";
echo "<meta http-equiv='refresh' content='0;URL=product.php'>";
exit();
}
if($check == 1 && $proid <> ""){
$sql_product = "select * from product where product_id = '$proid' ";
$result_product = mysql_query($sql_product);
$query_product = mysql_fetch_array($result_product);
$sess_productid[] = $query_product['product_id'];
$sess_productbrand[] = $query_product["product_brand"];
$sess_productprice[] = $query_product['product_price'];
$sess_productqty[] = 1;
echo "<meta http-equiv='refresh' content='0;URL=BasketAdd.php'>";
}
?>
</body>
</html>
<?
include "closeDb.php";
?>
BasketAdd.php
<?
session_start();
ob_start();
include "connect.php";
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>ตระกร้าสินค้า</title>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.register {
font-size: 12px;
}
.footer {
font-size: 14px;
font-weight: bold;
}
body {
background-image: url(Image/BG.gif);
}
</style>
<script language="javascript">
function chknum(){
key=event.keyCode;
if(key<48 || key>57){
event.returnValue=false;
}
}
</script>
</head>
<body>
<div align="center">
<table width="1000" height="250" border="0">
<tr>
<td><img src="Image/Header.jpg" width="1000" height="250" /></td>
</tr>
</table>
</div>
<div align="center">
<table width="1000" border="0">
<tr>
<td><ul id="MenuBar1" class="MenuBarHorizontal">
<li><a href="Index.php">หน้าแรก</a> </li>
<li><a href="Product.php" class="MenuBarItemSubmenu">สินค้า</a>
<ul>
<?
$sql_producttype = "select * from producttype";
$result_producttype = mysql_query($sql_producttype);
while($query_producttype = mysql_fetch_array($result_producttype)){
?>
<li><a href="Product.php?producttype=<?=$query_producttype["producttype_id"];?>"><?=$query_producttype["producttype_name"];?></a></li>
<?
}
?>
</ul>
</li>
<li><a href="Consignment.php">ฝากขายสินค้า</a></li>
<li><a href="News.php">ข่าวสาร</a></li>
<li><a href="Webboard.php">เว็บบอร์ด</a></li>
</ul></td>
</tr>
</table>
</div>
<div align="center">
<table width="1000" border="0">
<tr>
<td width="250" align="center" valign="top">
<?
if(($_SESSION['member_id'] == "") || ($_SESSION['status'] != "USER")){
header("location:Login.php");
}else{
$sql_member = "select * from member where member_id = '".$_SESSION['member_id']."' ";
$result_member = mysql_query($sql_member);
$query_member = mysql_fetch_array($result_member);
?>
<form id="Login" name="Login" method="post" action="logout.php">
<table width="250" border="0">
<tr>
<td colspan="2" align="left" valign="middle">สวัสดี</td>
</tr>
<tr>
<td width="80" align="left" valign="middle">คุณ :</td>
<td width="159" align="left" valign="middle"><?=$query_member["username"];?></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" class="register"><a href="EditUser.php">แก้ไขข้อมูลส่วนตัว</a></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" class="register"><a href="ConsignmentUser.php">สินค้าฝากขาย</a></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" class="register"><a href="Returns.php">คืนสินค้า</a></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" class="register"><a href="Status.php">สถานะการสั่งซื้อสินค้า</a></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" class="register"><?=$_SESSION['member_id'];?></td>
</tr>
<tr>
<td align="center" valign="middle" class="register"> </td>
<td align="left" valign="middle"><input type="submit" name="button" id="button" value="Logout" /></td>
</tr>
</table>
</form>
<?
}
?>
</td>
<td width="750" align="center" valign="top">
<form id="product" name="product" method="post" action="BasketCal.php">
<?
if(count($sess_productid)==0){
?>
<table width="750" border="0">
<tr>
<td colspan="7"> </td>
</tr>
<tr>
<td colspan="7"> </td>
</tr>
<tr>
<td colspan="7"> </td>
</tr>
<tr>
<td colspan="7"> </td>
</tr>
<tr>
<td colspan="7" align="center" valign="middle">ยังไม่มีสินค้าในตระกร้า</td>
</tr>
<tr>
<td colspan="7" align="center" valign="middle"> </td>
</tr>
<tr>
<td colspan="7" align="center" valign="middle"> </td>
</tr>
</table>
<?
}else{
?>
<table width="750" border="0">
<tr>
<td colspan="7" align="center" valign="middle"> </td>
</tr>
<tr>
<td colspan="7" align="center" valign="middle">ตระกร้าสินค้า</td>
</tr>
<tr>
<td colspan="7"></td>
</tr>
<tr>
<td width="75" align="center" valign="middle">ลบ</td>
<td width="183" align="center" valign="middle">รหัสสินค้า</td>
<td width="184" align="center" valign="middle">สินค้า</td>
<td width="80" align="center" valign="middle">จำนวน</td>
<td width="80" align="center" valign="middle">ราคา</td>
<td width="80" align="center" valign="middle">ราคารวม</td>
<td width="40" align="center" valign="middle"> </td>
</tr>
<?
$num=0;
for($i=0; $i<count($sess_productid); $i++){
if($sess_productbrand[$i] <> ""){
$total_unit = $sess_productprice[$i] * $sess_productqty[$i];
$total = $total + $total_unit;
$price = number_format($sess_productprice[$i]);
$t_unit = number_format($total_unit);
?>
<tr>
<td align="center" valign="middle">
<input type="checkbox" name="prd_del[]" value="<?=$sess_productid[$i];?>">
</td>
<td align="center" valign="middle"><?=$sess_productid[$i];?></td>
<td align="center" valign="middle"><?=$sess_productbrand[$i];?></td>
<td align="center" valign="middle">
<input type="text" name="prd_productqty[]" value="<?=$sess_productqty[$i];?>" size="2" onkeypress="chknum()">
</td>
<td align="center" valign="middle"><?=$price;?></td>
<td align="center" valign="middle"><?=$t_unit;?></td>
<td align="center" valign="middle"> </td>
</tr>
<?
}
}
$t=number_format($total);
?>
<tr>
<td align="center" valign="middle"> </td>
<td align="center" valign="middle"> </td>
<td align="center" valign="middle"> </td>
<td align="center" valign="middle"> </td>
<td align="center" valign="middle"> </td>
<td align="center" valign="middle"> </td>
<td align="center" valign="middle"> </td>
</tr>
<tr>
<td colspan="5" align="right" valign="middle">ราคารวม :</td>
<td align="center" valign="middle">
<?
$t=number_format($total);
echo "$t";
?>
</td>
<td align="center" valign="middle">บาท</td>
</tr>
<tr>
<td colspan="7" align="center" valign="middle"> </td>
</tr>
<tr>
<td colspan="7" align="right" valign="middle">
<input type="hidden" name="btn" value="1">
<input type="submit" name="calculate" id="calculate" value="คำนวณใหม่" />
<input type="submit" name="complete" id="complete" value="สั่งซื้อสินค้า" />
</td>
</tr>
</table>
<?
}
?>
</form>
</td>
</tr>
</table>
</div>
<div align="center">
<table width="1000" border="0">
<tr>
<td align="center" valign="middle"><br />
<span class="footer">Copyright © 2014 All rights reserved. Do not duplicate or redistribute in any form prior permission.</span><br />
<br /></td>
</tr>
</table>
</div>
<script type="text/javascript">
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
</script>
</body>
</html>
<?
include "closeDb.php";
?>
BasketCal.php
<?
session_start();
ob_start();
include "connect.php";
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>คำนวณ</title>
</head>
<body>
<?
if(count($prd_del)==0){
$prd_del = array();
}
for($i=0; $i<count($sess_productid); $i++){
if(!in_array($sess_productid[$i],$prd_del)){
$temp_productid[] = $sess_productid[$i];
$temp_productbrand[] = $sess_productbrand[$i];
$temp_productprice[] = $sess_productprice[$i];
$temp_productqty[] = $prd_productqty[$i];
}
}
$sess_productid = $temp_productid;
$sess_productbrand = $temp_productbrand;
$sess_productprice = $temp_productprice;
$sess_productqty = $temp_productqty;
if($calculate){
echo"<meta http-equiv='refresh' content='0;URL=BasketAdd.php?ch=1' />";
}else if($complete){
echo"<meta http-equiv='refresh' content='0;URL=CustomerData.php' />";
}
?>
</body>
</html>
CustomerData.php
<?
session_start();
ob_start();
include "connect.php";
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>สั่งซื้อสินค้า</title>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.register {
font-size: 12px;
}
.footer {
font-size: 14px;
font-weight: bold;
}
body {
background-image: url(Image/BG.gif);
}
</style>
</head>
<body>
<div align="center">
<table width="1000" height="250" border="0">
<tr>
<td><img src="Image/Header.jpg" width="1000" height="250" /></td>
</tr>
</table>
</div>
<div align="center">
<table width="1000" border="0">
<tr>
<td><ul id="MenuBar1" class="MenuBarHorizontal">
<li><a href="Index.php">หน้าแรก</a> </li>
<li><a href="Product.php" class="MenuBarItemSubmenu">สินค้า</a>
<ul>
<?
$sql_producttype = "select * from producttype";
$result_producttype = mysql_query($sql_producttype);
while($query_producttype = mysql_fetch_array($result_producttype)){
?>
<li><a href="Product.php?producttype=<?=$query_producttype["producttype_id"];?>"><?=$query_producttype["producttype_name"];?></a></li>
<?
}
?>
</ul>
</li>
<li><a href="Consignment.php">ฝากขายสินค้า</a></li>
<li><a href="News.php">ข่าวสาร</a></li>
<li><a href="Webboard.php">เว็บบอร์ด</a></li>
</ul></td>
</tr>
</table>
</div>
<div align="center">
<table width="1000" border="0">
<tr>
<td width="250" align="center" valign="top">
<?
if(($_SESSION['member_id'] == "") || ($_SESSION['status'] != "USER")){
header("location:Login.php");
}else{
$sql_member = "select * from member where member_id = '".$_SESSION['member_id']."' ";
$result_member = mysql_query($sql_member);
$query_member = mysql_fetch_array($result_member);
?>
<form id="Login" name="Login" method="post" action="logout.php">
<table width="250" border="0">
<tr>
<td colspan="2" align="left" valign="middle">สวัสดี</td>
</tr>
<tr>
<td width="80" align="left" valign="middle">คุณ :</td>
<td width="159" align="left" valign="middle"><?=$query_member["username"];?></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" class="register"><a href="EditUser.php">แก้ไขข้อมูลส่วนตัว</a></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" class="register"><a href="ConsignmentUser.php">สินค้าฝากขาย</a></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" class="register"><a href="Returns.php">คืนสินค้า</a></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" class="register"><a href="Status.php">สถานะการสั่งซื้อสินค้า</a></td>
</tr>
<tr>
<td align="center" valign="middle" class="register"> </td>
<td align="left" valign="middle"><input type="submit" name="button" id="button" value="Logout" /></td>
</tr>
</table>
</form>
<?
}
?>
</td>
<td width="750" align="center" valign="top">
<form id="customer" name="customer" method="post" action="Info.php">
<table width="750" border="0">
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2" align="center" valign="middle">ข้อมูลลูกค้าสำหรับจัดส่งสินค้า</td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td width="375" align="right" valign="middle">ชื่อ - นามสกุล :</td>
<td width="365" align="left" valign="middle"><?=$query_member["fname"];?> <?=$query_member["lname"];?></td>
</tr>
<tr>
<td align="right" valign="middle">ที่อยู่ :</td>
<td align="left" valign="middle"><?=$query_member["address"];?></td>
</tr>
<tr>
<td align="right" valign="middle">เบอร์โทร :</td>
<td align="left" valign="middle"><?=$query_member["tel"];?></td>
</tr>
<tr>
<td align="right" valign="middle">E-Mail :</td>
<td align="left" valign="middle"><?=$query_member["email"];?></td>
</tr>
<tr>
<td align="right" valign="middle"> </td>
<td align="left" valign="middle"> </td>
</tr>
<tr>
<td colspan="2" align="center" valign="middle">
<input type="submit" name="button2" id="button2" value="ยืนยันข้อมูล" />
</td>
</tr>
<tr>
<td align="right" valign="middle"> </td>
<td align="left" valign="middle"> </td>
</tr>
</table>
</form>
</td>
</tr>
</table>
</div>
<div align="center">
<table width="1000" border="0">
<tr>
<td align="center" valign="middle"><br />
<span class="footer">Copyright © 2014 All rights reserved. Do not duplicate or redistribute in any form prior permission.</span><br />
<br /></td>
</tr>
</table>
</div>
<script type="text/javascript">
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
</script>
</body>
</html>
<?
include "closeDb.php";
?>
Info.php
<?
session_start();
ob_start();
include "connect.php";
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>สินค้า</title>
<script src="SpryAssets/SpryMenuBar.js" type="text/javascript"></script>
<link href="SpryAssets/SpryMenuBarHorizontal.css" rel="stylesheet" type="text/css" />
<style type="text/css">
.register {
font-size: 12px;
}
.footer {
font-size: 14px;
font-weight: bold;
}
body {
background-image: url(Image/BG.gif);
}
</style>
</head>
<body>
<div align="center">
<table width="1000" height="250" border="0">
<tr>
<td><img src="Image/Header.jpg" width="1000" height="250" /></td>
</tr>
</table>
</div>
<div align="center">
<table width="1000" border="0">
<tr>
<td><ul id="MenuBar1" class="MenuBarHorizontal">
<li><a href="Index.php">หน้าแรก</a> </li>
<li><a href="Product.php" class="MenuBarItemSubmenu">สินค้า</a>
<ul>
<?
$sql_producttype = "select * from producttype";
$result_producttype = mysql_query($sql_producttype);
while($query_producttype = mysql_fetch_array($result_producttype)){
?>
<li><a href="Product.php?producttype=<?=$query_producttype["producttype_id"];?>"><?=$query_producttype["producttype_name"];?></a></li>
<?
}
?>
</ul>
</li>
<li><a href="Consignment.php">ฝากขายสินค้า</a></li>
<li><a href="News.php">ข่าวสาร</a></li>
<li><a href="Webboard.php">เว็บบอร์ด</a></li>
</ul></td>
</tr>
</table>
</div>
<div align="center">
<table width="1000" border="0">
<tr>
<td width="250" align="center" valign="top">
<?
if(($_SESSION['member_id'] == "") || ($_SESSION['status'] != "USER")){
header("location:Login.php");
}else{
$sql_member = "select * from member where member_id = '".$_SESSION['member_id']."' ";
$result_member = mysql_query($sql_member);
$query_member = mysql_fetch_array($result_member);
?>
<form id="Login" name="Login" method="post" action="logout.php">
<table width="250" border="0">
<tr>
<td colspan="2" align="left" valign="middle">สวัสดี</td>
</tr>
<tr>
<td width="80" align="left" valign="middle">คุณ :</td>
<td width="159" align="left" valign="middle"><?=$query_member["username"];?></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" class="register"><a href="EditUser.php">แก้ไขข้อมูลส่วนตัว</a></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" class="register"><a href="ConsignmentUser.php">สินค้าฝากขาย</a></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" class="register"><a href="Returns.php">คืนสินค้า</a></td>
</tr>
<tr>
<td colspan="2" align="left" valign="middle" class="register"><a href="Status.php">สถานะการสั่งซื้อสินค้า</a></td>
</tr>
<tr>
<td align="center" valign="middle" class="register"> </td>
<td align="left" valign="middle"><input type="submit" name="button" id="button" value="Logout" /></td>
</tr>
</table>
</form>
<?
}
?>
</td>
<td width="750" align="center" valign="top">
<form id="info" name="info" method="post" action="Order.php">
<table width="750" bgcolor="#C1D6FF" border="1" bordercolor="#000000">
<tr>
<td colspan="6"> </td>
</tr>
<tr>
<td colspan="6" align="center" valign="middle"><b><u>สรุปรายการสินค้าที่สั่งซื้อ</u></b></td>
</tr>
<tr>
<td colspan="6"> </td>
</tr>
<tr>
<td width="80" align="center" valign="middle">รายการที่</td>
<td width="80" align="center" valign="middle">รหัสสินค้า</td>
<td width="264" align="center" valign="middle">สินค้า</td>
<td width="100" align="center" valign="middle">จำนวน</td>
<td width="100" align="center" valign="middle">ราคา</td>
<td width="100" align="center" valign="middle">ราคารวม</td>
</tr>
<?
session_register(sess_total);
$num=0;
for($i=0; $i<count($sess_productid); $i++){
if($sess_productbrand[$i]<>""){
$total_unit = $sess_productprice[$i] * $sess_productqty[$i];
$total = $total + $total_unit;
$price = number_format($sess_productprice[$i]);
$t_unit = number_format($total_unit);
$num++;
?>
<tr>
<td align="center" valign="middle"><?=$num;?></td>
<td align="center" valign="middle"><?=$sess_productid[$i];;?></td>
<td align="center" valign="middle"><?=$sess_productbrand[$i];?></td>
<td align="center" valign="middle"><?=$sess_productqty[$i];?></td>
<td align="center" valign="middle"><?=$price;?></td>
<td align="center" valign="middle"><?=$t_unit;?></td>
</tr>
<?
}
}
$t=number_format($total);
$t1=$total;
$_SESSION[sess_total]=$t1;
?>
<tr>
<td colspan="6" align="right" valign="middle"><b>ราคารวม <?=$t;?> บาท</b></td>
</tr>
</table>
<p>
<input type="submit" name="button2" id="button2" value="สั่งซื้อสินค้า" />
</p>
</form>
</td>
</tr>
</table>
</div>
<div align="center">
<table width="1000" border="0">
<tr>
<td align="center" valign="middle"><br />
<span class="footer">Copyright © 2014 All rights reserved. Do not duplicate or redistribute in any form prior permission.</span><br />
<br /></td>
</tr>
</table>
</div>
<script type="text/javascript">
var MenuBar1 = new Spry.Widget.MenuBar("MenuBar1", {imgDown:"SpryAssets/SpryMenuBarDownHover.gif", imgRight:"SpryAssets/SpryMenuBarRightHover.gif"});
</script>
</body>
</html>
<?
include "closeDb.php";
?>
Order.php
<?
session_start();
ob_start();
include "connect.php";
?>
<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>สั่งซื้อสินค้า</title>
</head>
<body>
<?
$memberid = $_SESSION["member_id"];
$t = $_SESSION['sess_total'];
$status = 1;
$sql_order = "select * from `order` order by order_id desc ";
$result_order = mysql_query($sql_order);
$query_order = mysql_fetch_array($result_order);
$orderid = $query_order['order_id'] + 1;
$sql_order1 = "insert into `order`
values('$orderid',now(),'$t','$status','$memberid')";
$result_order1 = mysql_query($sql_order1);
for($i=0; $i<count($sess_productid); $i++){
$product_id = $sess_productid[$i];
$product_qty = $sess_productqty[$i];
$product_price = $sess_productprice[$i]*$sess_productqty[$i];
$sql_orderdetail = "insert into orderdetail(order_id , product_id , product_qty , total_product_price)
values('$orderid','$product_id','$product_qty','$product_price')";
$result_orderdetail = mysql_query($sql_orderdetail);
}
if(($result_order == true)&&($result_order1 == true)&&($result_orderdetail == true)){
session_unregister("sess_productid");
session_unregister("sess_productbrand");
session_unregister("sess_productqty");
session_unregister("sess_productprice");
session_unregister("sess_total");
echo "<script>alert('บันทึกรายการสั่งซื้อเรียบร้อย')</script>";
echo "<meta http-equiv='refresh' content='0;URL=Product.php'>";
}else{
session_unregister("sess_productid");
session_unregister("sess_productbrand");
session_unregister("sess_productqty");
session_unregister("sess_productprice");
session_unregister("sess_total");
echo "<script>alert('ไม่สามารถบันทึกรายการสั่งซื้อได้')</script>";
echo "<meta http-equiv='refresh' content='0;URL=product.php'>";
}
?>
</body>
</html>
<?
include "closeDb.php";
?>
ในรูปที่ 6 จะเห็นได้ว่า ผมดึงค่า Session ไว้ใต้ Text Field
Code (PHP)
<?=$_SESSION['member_id'];?>
ซึ่งผมใช้ member_id ที่ 3 login
ไม่ทราบว่าทำไมเวลาสั่งซื้อสินค้า แล้วเหมือน Session มันหลุดอ่ะครับ
ปล.โทษทีนะครับยาวไปหน่อย
Tag : PHP
|
|
|
|
|
|
Date :
2014-09-23 09:45:12 |
By :
nestzamaster |
View :
985 |
Reply :
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เหมือนกับจะได้ละ เดียวลอง เช็คดูอีกทีก่อน
|
|
|
|
|
Date :
2014-09-23 09:50:54 |
By :
nestzamaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
555 ไม่ได้อยู่ดี
|
|
|
|
|
Date :
2014-09-23 09:54:42 |
By :
nestzamaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|