Jump to content

Recommended Posts

<button type="submit" class="submit" name="submit">Add to cart</button>

Use that instead of the button you have, and on cart.php Use something like this..

 

if(isset($_POST['submit'])){
$id = $_POST['productid'];
echo $id;
}

 

You need to do further tests.

Hi and thanks for all your help.

 

I have now passed my product id to my cart page and performed sql  to display the details of that product.

 

Heres the code

 

<?php 

		/*Get the product id from previos page*/
		$productid = $_GET['productid'];



		/*get the product details based on id*/
		$query = "select ProductID, ProductName, ProductPrice
		FROM product 
		WHERE ProductID = ".$productid;		
		$result = mysql_query($query, $conn)
		  or die ("Unable to perform query");
		  
		while($row= mysql_fetch_array($result))
		{
            	
            	echo $row["ProductName"];
            	echo $row["ProductPrice"];
		}

		//* Save details to the session*//



	?>

 

What i now want to do is save the product details to a session.

How do i do the next step of saving every product id thats past to this page to the session variable and not overwrite it, so then when i get to the payment section i can pass the total over to paypal?

 

 

Well,

$_SESSION['session-name'] = $id;

That would set a session, although if you're wanting to set a session for each ID without overwriting. Then try something similar to;

$_SESSION["$id"] = $id;

For product id 1, the session name will be $_SESSION["1"] which will hold the value 1.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.