jwk811 Posted September 6, 2006 Share Posted September 6, 2006 How will I get data using php when I user clicks on a button? I want it so when someone clicks add to cart the item will go to another (their cart) and so will they to check it. I need that data to stay there even when they go to another page and some back. If someone could give me more detailed information that would be great but right now I'm just trying to get this one part down. Quote Link to comment Share on other sites More sharing options...
mitzleah Posted September 6, 2006 Share Posted September 6, 2006 Hey,Put this on the top of the page:$_SESSION['cart']['first_name'] = $_POST['first_name']Just like that! Hope this helps! :) Quote Link to comment Share on other sites More sharing options...
jwk811 Posted September 6, 2006 Author Share Posted September 6, 2006 do i put one of those for every item? instead of having full_name put the item and make a new line for each other item? then when they click the button they will go to there cart and i can... wait im stuck how will i get that item there. Quote Link to comment Share on other sites More sharing options...
btherl Posted September 6, 2006 Share Posted September 6, 2006 You might also need to call session_start() at the top of your page too (before ANY html at all, even blank lines. If you have trouble, check the thread on header errors).You might not need to call it, it depends on your php configuration.Once sessions are active (triggered by session_start()), then any data you place into the $_SESSION[] array will be available between requests. Quote Link to comment Share on other sites More sharing options...
jwk811 Posted September 6, 2006 Author Share Posted September 6, 2006 How will I get that data to the other page? If I have session_start at the top. Then where my button is that says add to cart how will I be able to add that item to the cart? $_SESSION[]... what do i put between the brackets and how to make the info send? Do I add that in the form somehow? Quote Link to comment Share on other sites More sharing options...
mitzleah Posted September 6, 2006 Share Posted September 6, 2006 btherl is right you must first call session_start(). ;D Quote Link to comment Share on other sites More sharing options...
jwk811 Posted September 6, 2006 Author Share Posted September 6, 2006 I know that, this was my message.[quote]How will I get that data to the other page? If I have session_start at the top. Then where my button is that says add to cart how will I be able to add that item to the cart? $_SESSION[]... what do i put between the brackets and how to make the info send? Do I add that in the form somehow?[/quote]Now how am I going to get this to work? Quote Link to comment Share on other sites More sharing options...
mitzleah Posted September 6, 2006 Share Posted September 6, 2006 @jwk811like this:session_start();$_SESSION['cart']['first_name'] = $_POST['first_name'];//FORM<input name="first_name" value="Yes" type="textfield" value="<?php echo $_SESSION['cart']['first_name'] ?>">Hope you do get it!Goodluck dude! Quote Link to comment Share on other sites More sharing options...
jwk811 Posted September 6, 2006 Author Share Posted September 6, 2006 okay i think thats what i needed.. thank you :D Quote Link to comment Share on other sites More sharing options...
karthikeyan_coder Posted September 6, 2006 Share Posted September 6, 2006 put ob_start(); after session_start(); and put ob_end_flush(); at before ?> tag... it will help to block the php session warnings... if you have any doubt about it then ask me here... Quote Link to comment Share on other sites More sharing options...
redarrow Posted September 6, 2006 Share Posted September 6, 2006 you relly should never use ob_start if there is an error then solve it.in my option ob_start(); is a tempary method and a lazy solution.sorry. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.