Jump to content

Session?


DarkPrince2005

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.