$ _SESSION ['']进入数据库

时间:2014-05-22 13:40:56

标签: php mysql sql session phpmyadmin

我已经在$_SESSION[' ']的phpmyadmin customer表中找到了值(在其中包含idcust_namecust_firstname,{{1 }},cust_lastnamecust_addcust_tel),我将此用于登录目的。

然后在我的cust_email中声明类似

的内容
SessionHandler.php

所以,每当有人登录我只会使用//check whether the query was successful or not if(isset($result)) { if(mysql_num_rows($result) == 1) { //Login successful session_regenerate_id(); $member = mysql_fetch_assoc($result); $_SESSION['SESS_CUST_ID'] = $member['id']; $_SESSION['SESS_CUST_EMAIL'] = $member['cust_email']; $_SESSION['SESS_CUST_NAME'] = $member['cust_name']; $_SESSION['SESS_CUST_FIRST'] = $member['cust_firstname']; $_SESSION['SESS_CUST_ADD'] = $member['cust_add']; $_SESSION['SESS_CUST_TEL'] = $member['cust_tel']; $_SESSION['STATUS'] = true; session_write_close(); header("location: http://localhost/wedding/user/dresses.php"); exit(); } else { //login failed header("location: cust-login-failed.html"); exit(); } } else { die("Query failed"); } 问题是,我正在做一个购物车,我希望登录的客户名称或我希望<?php echo $_SESSION['SESS_CUST_FIRST'] ?>的其他单词以新表名$_SESSION['SESS_CUST_FIRST']插入到数据库中orderidproduct_nameproduct_codepriceproduct_sizeproduct_qty

这是衣服页面中的按钮添加到购物车的表单:

cust_firstname

但每当我开始添加到购物车时,它将首先提交给<form method="POST" action="dress-isikan.php"> <table> <tr> <td colspan="1" rowspan="5"><img src="/wedding/dress/Large/01.jpg"></td> <td style="vertical-align: top;"><big style="font-family: DFKai-SB;">Tulip Wedding Dress (WD01)<input type="hidden" name="product_name" value="Tulip Dress"> </td> </tr> <tr> <td><input type="hidden" name="product_code" value="WD01"></td> </tr> <tr> <td style="vertical-align: top;">Beautiful tulip wedding dress with flower lace on the chest</td> </tr> <tr align="center"> <td style="vertical-align: top;">Price: RM 799 <input type="hidden" name="price" value="799.00"><br> <br> Size :</big> <select name="product_size"> <option>34</option> <option>36</option> <option>38</option> <option>40</option> <option>42</option> <option>44</option> <option>46</option> <option>48</option> </select> </big> </td> </tr> <tr> <td style="vertical-align: top; text-align: center;"><br><big><big> <input type="hidden" value="<?php echo $_SESSION['SESS_CUST_FIRST']; ?>" name="$cust_name;"> Quantity:</big></big> <input type="number" name="product_qty" min="1" max="11" value="1"><br> <br> <input type="submit" class="btn btn-default" value="Add to cart" ><br> </td> </tr> </table> </form>

dress-isikan.php

它会说<!-- dress-isikan.php --> <!-- To insert data of masuk.php into database. --> <?php include("dress-dbase.php"); extract( $_POST ); $query = "INSERT INTO order VALUES ('', '$cust_name', '$product_name','$product_code','$price','$product_qty','$product_size')"; $result = mysql_query($query, $conn) or die("Could not execute query in dress-isikan.php"); if($result) { echo "<script type='text/javascript'> window.location='checkout.php' </script>"; } ?> 无法执行查询,我不知道查询有什么问题。我想我没有做错任何事。有时,我尝试将其提交到数据库表dress-isikan.php中的$_SESSION[' ']事件总是有问题。我只是按照我的讲义。有谁知道吗?

0 个答案:

没有答案