我已附上网页代码
$id = $_GET['id'];
$_SESSION['abaya']= $id;
以上代码是我获取ID的地方。我附上了下面的特定页面
<!DOCTYPE html>
<html lang="en"><head>
<meta charset="utf-8">
<title>Abayat Dubai</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
</head>
<body>
<section id="portfolio" class="portfolio">
<div class="container">
<div class="row">
<div class="span6" style="float:left">
<?php
$code="{$_SESSION['abaya']}";
?>
<!--begin span4 -->
<div class="view view-first" id="frockone">
<img src="images/photos/<?php echo"$code";?>.jpg" alt="frock">
</div>
</div>
<div class="span5" style="float: right; padding-left:5%">
<?php
$query="SELECT * FROM s_product WHERE code='$code';";
$result=mysql_query($query)
or die("could not perform query");
$name="{$_SESSION['country']}";
$price="error";
while($row=mysql_fetch_array($result,MYSQL_ASSOC))
{
$p_name="{$row['img_name']}";
?>
<h4><?php echo"{$row['img_name']}";?></h4>
<p>Description : <?php echo"{$row['description']}";?> </p>
<?php if($name=="sri"){
$currency="LKR ";
$price="{$row['sri_price']}";
}
elseif($name=="uae"){
$currency="AED ";
$price="{$row['price']}";
}
elseif($name=="australia"){
$currency="AUD ";
$price="{$row['australia_price']}";
}
else{
$currency="USD ";
$price="{$row['usa_price']}";
}?>
<h6 style="color:#a62b6d; font-size:18px"> <span><?php echo"$currency","$price"?></span></h6>
<?php
$price_us="{$row['usa_price']}";
break;
}?>
<hr>
<div>
<form name="product" method="post" action="pro.php">
<select name="quantity" style="width:100px; padding:2%">
<option selected="selected" value="">Quantity</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select><br />
<select name="size" style="width:100px; padding:2%">
<option selected="selected" value="">Size</option>
<option value="50">50</option>
<option value="52">52</option>
<option value="54">54</option>
<option value="56">56</option>
<option value="58">58</option>
</select>
<br /><br />
<input type="submit" class="btn btn-small btn-primary btn-embossed but" value="Add To Bag" onclick="return validate()" name="add_cart" style="margin-right:5%"/>
<a href="sale_home.php"> Continue shopping!</a>
<br />
</form>
<?php
if(isset($_SESSION['user_tempid']))
{?>
<?php }else{
date_default_timezone_set('Asia/Dubai');
$today = date("Y-m-d H:i:s");
$_SESSION['user_tempid']="$today";
$i=1;
$query8="select * from temp_id;";
$result8=mysql_query($query8) or die("can not login");
while($row=mysql_fetch_array($result8,MYSQL_ASSOC)){
if($row['id']=="$today"){
$_SESSION['user_tempid']="$today$i";
$i++;
}
}
}
?>
<?php
if(isset($_POST["add_cart"]))
{
$quantity=$_POST["quantity"];
$size=$_POST["size"];
$cost=$quantity*$price;
$usd=$quantity*$price_us;
$query="INSERT INTO temp_cartitem(user_id,product_id,size,quantity,ori_price,cost,product_name,currency,usd) VALUES('{$_SESSION['user_tempid']}','$code','$size','$quantity','$price','$cost','$p_name','$currency','$usd')";
$result= mysql_query($query) or die("failed to insert your record");
//header('location:cart.php');
}
?>
</div>
<hr>
</div>
</div>
<br /><br /><br />
<!--end small list-->
</div>
</section>
</div>
</body>
</html>
答案 0 :(得分:0)
您是否在为会话变量赋值之前发出了session_start()?