DarkPrince2005 Posted July 23, 2008 Share Posted July 23, 2008 I'm having some trouble inserting the session into a database through my php, but it doesn't seem to be working. Can anyone help. <?php session_start(); //connect to database $conn = mysql_connect("localhost", "root", "") or die(mysql_error()); mysql_select_db("pc_lan_it",$conn) or die(mysql_error()); if ($_POST[product_name] != "") { //validate item and get title and price $get_iteminfo = "select * from tbl_product where product_id = $_POST[product_id]"; $get_iteminfo_res = mysql_query($get_iteminfo) or die(mysql_error()); if (mysql_num_rows($get_iteminfo_res) < 1) { } else { //get info $item_title = mysql_result($get_iteminfo_res,0,'product_id'); //add info to cart table $addtocart = "insert into tbl_cart values ('', '$_POST[product_id]', '1', '$PHPSESSID',now())"; mysql_query($addtocart); //redirect to showcart page header("Location: showcart.php"); exit; } } else { exit; } ?> Link to comment https://forums.phpfreaks.com/topic/116291-session/ Share on other sites More sharing options...
.josh Posted July 23, 2008 Share Posted July 23, 2008 $sess = session_id(); $addtocart = "insert into tbl_cart values ('', '$_POST[product_id]', '1', '$sess',now())"; Link to comment https://forums.phpfreaks.com/topic/116291-session/#findComment-598035 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.