views:

55

answers:

3

I want to know the way of passing multidimensional in URL with php.
I have an array like this

$number  = $_SESSION["number"];  
$number = $number+1;  
$_SESSION["number"] = $number;  
$_SESSION['count']$number]=array($_POST['buy_app_page'],$_POST['x'],$_POST['y'],$_POST['w'],$_POST['h'],$_POST['selected_values'],$number);
$pixels_detail=$_SESSION['count'];
$pixels_detail=$_SESSION['count'];

I want to pass the session data stored in the $pixels_detail variable to url. I tried to to this but it show a blank parameter without any value in the url.

Actually am storing cart data in an session array and have two buttons when the user done adding products he/she clicks on the continue button this is where I want to the whole session data to be passed to the next page in any way, using url or someother I haven't any idea now!

Please Help.

+3  A: 

Why do you want to pass data to the url? Usually storing it in the session is the best way to do it. If you want to pass complex data in the URL you might have a look at the serialize() and unserialize() funtions of PHP.

There is also the really nice funtion http_build_query() that converts complex data. But be aware of the 4096 character limit of a query string. I would really recommend to read the data from the session as far as you don't have any argument against it. You might pass only one parameter with the button and then read the corresponding data from the session.

Kau-Boy
I did it with serialize and unserialize with php it works but in url it has all the serialized string.Actually what am doing is thatI have a page where user comes to select a product there are two buttons e.g. Add another and Continue I have to check if the user just clicked the continue button then the form should take the data to next page in a normal way else if the user clicked and on add another button and added any no of products then it should go to next page with all the data in the session array.Thanks for your quick answer please tell me again.thanks
junjua
(would +1 but out of votes) yeah, this really doesn't make much sense: Sessions exist to persist data across requests. If you want to prevent multiple requests from the same client mixing up your data, put the data into a session variable with a random key, and pass through that key. GET parameters are seriously limited in what they can carry.
Pekka
URLs in general have limits as well. IE6 supports up to only 256 characters (Ask me how I found that out ;-) )... Most modern support a lot, but Apache only supports up to [around 8177 bytes](http://stackoverflow.com/questions/1289585/what-is-apaches-maximum-url-length)
ircmaxell
I didn't completely understand your comment. But as I said, I would just send two diffrent values on the two buttons and than run the action (e.g. adding something to the cart) on the very next page according to the parameter from the button.
Kau-Boy
@Pekka: Thanks. You can +1 me tomorrow :)
Kau-Boy
+1  A: 
Helgi Hrafn Gunnarsson
I want a clean url like this http://www.mysite.com/somepage.php?req=somesinglevar
junjua
I have not added any action page for this my action page is the page from which am posting data. How can I check and send form data if the continue button is clicked and to next page in one click.?
junjua
I mean if the continue button is clicked the data should be passed to next page using any redirect with all post data otherwise if the add anther button is clicked the session data should be passed to the next page.Thanks a lot please help
junjua
A: 

i think i saw here a function do that

moustafa