Re: [PHP] POST arrays?
William Stokes wrote: How to post an array with associated values? This works ok ?php $arr_siirto = array(1,2,3); print_r($arr_siirto); $arse = $arr_siirto; print_r($arse); ? But if I post it to another form with this: input type=hidden name=arr_siirt_jouk value=?php echo $arse;? And print there with: print_r($arr_siirt_jouk); prints: Array So how can post the values forward? http://php.net/serialize -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
No other way? Stut [EMAIL PROTECTED] kirjoitti viestissä:[EMAIL PROTECTED] William Stokes wrote: How to post an array with associated values? This works ok ?php $arr_siirto = array(1,2,3); print_r($arr_siirto); $arse = $arr_siirto; print_r($arse); ? But if I post it to another form with this: input type=hidden name=arr_siirt_jouk value=?php echo $arse;? And print there with: print_r($arr_siirt_jouk); prints: Array So how can post the values forward? http://php.net/serialize -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
On 4/20/06, William Stokes [EMAIL PROTECTED] wrote: Hello, How to post an array with associated values? This works ok ?php $arr_siirto = array(1,2,3); print_r($arr_siirto); $arse = $arr_siirto; print_r($arse); ? But if I post it to another form with this: input type=hidden name=arr_siirt_jouk value=?php echo $arse;? And print there with: print_r($arr_siirt_jouk); prints: Array So how can post the values forward? Instead of posting the values forward, you could store it all in a session and access it that way. -- Postgresql php tutorials http://www.designmagick.com/ -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
William Stokes wrote: No other way? Over sessions or saving as file and loading it in the following page. -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
Can someone help me to get started with serializing? I think I did'nt quite understand the manual here... How to post to $PHP_SELF and read this simple array? ? //print the posted array here print_r($arr_siirt_jouk); //create the array and post it in another name $arr_siirto = array(1,2,3); input type=hidden name=arr_siirt_jouk value=?php echo $arr_siirto;? ? I tried: ? //print the posted array here unserialize($arr_siirt_jouk); print_r($arr_siirt_jouk); //create the array and post it in another name $arr_siirto = array((serialize('1','2','3')); input type=hidden name=arr_siirt_jouk value=?php echo $arr_siirto;? ? Which, to my great surprice, didn't work :) Thanks -Will Barry [EMAIL PROTECTED] kirjoitti viestissä:[EMAIL PROTECTED] William Stokes wrote: No other way? Over sessions or saving as file and loading it in the following page. -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
William Stokes wrote: Can someone help me to get started with serializing? I think I did'nt quite understand the manual here... How to post to $PHP_SELF and read this simple array? Why do you want to post it to itself? Why not use a session instead? It's a lot more efficient. ? //print the posted array here print_r($arr_siirt_jouk); //create the array and post it in another name $arr_siirto = array(1,2,3); input type=hidden name=arr_siirt_jouk value=?php echo $arr_siirto;? ? I tried: ? //print the posted array here unserialize($arr_siirt_jouk); You need to put the unserialized array somewhere, change this to $arr_siirt_jouk = unserialize($arr_siirt_jouk); print_r($arr_siirt_jouk); //create the array and post it in another name $arr_siirto = array((serialize('1','2','3')); Here you are still putting an array into the input field. You probably want $arr_siirto = serialize(array('1','2','3')); input type=hidden name=arr_siirt_jouk value=?php echo $arr_siirto;? ? Which, to my great surprice, didn't work :) I was surpriced too! Is the manual really that poorly written? I can't see how you got to your code by following the examples provided. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
William Stokes a écrit : Can someone help me to get started with serializing? I think I did'nt quite understand the manual here... serialize and unserialize don't modify your variable, but the return value is a string or a mixed (which means it can be a very complicated structure, or a simple array, an object, etc). first_script.php : $string_from_array = serialize($array); form action=second_script.php method=post input type=hidden name=art_siirt_jouk value=$string_from_array button type=button value=submit /form second_script.php : print_r($POST); $string = $_POST[art_siirt_jouk]; $array = unserialize($string); hope this'll help. N F How to post to $PHP_SELF and read this simple array? ? //print the posted array here print_r($arr_siirt_jouk); //create the array and post it in another name $arr_siirto = array(1,2,3); input type=hidden name=arr_siirt_jouk value=?php echo $arr_siirto;? ? I tried: ? //print the posted array here unserialize($arr_siirt_jouk); print_r($arr_siirt_jouk); //create the array and post it in another name $arr_siirto = array((serialize('1','2','3')); input type=hidden name=arr_siirt_jouk value=?php echo $arr_siirto;? ? Which, to my great surprice, didn't work :) Thanks -Will -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] POST arrays?
Have a look at : http://www.weberdev.com/AdvancedSearch.php?searchtype=titlesearch=serializ berber -Original Message- From: William Stokes [mailto:[EMAIL PROTECTED] Sent: Thursday, April 20, 2006 1:17 PM To: php-general@lists.php.net Subject: Re: [PHP] POST arrays? Can someone help me to get started with serializing? I think I did'nt quite understand the manual here... How to post to $PHP_SELF and read this simple array? ? //print the posted array here print_r($arr_siirt_jouk); //create the array and post it in another name $arr_siirto = array(1,2,3); input type=hidden name=arr_siirt_jouk value=?php echo $arr_siirto;? ? I tried: ? //print the posted array here unserialize($arr_siirt_jouk); print_r($arr_siirt_jouk); //create the array and post it in another name $arr_siirto = array((serialize('1','2','3')); input type=hidden name=arr_siirt_jouk value=?php echo $arr_siirto;? ? Which, to my great surprice, didn't work :) Thanks -Will Barry [EMAIL PROTECTED] kirjoitti viestissה:[EMAIL PROTECTED] William Stokes wrote: No other way? Over sessions or saving as file and loading it in the following page. -- Smileys rule (cX.x)C --o(^_^o) Dance for me! ^(^_^)o (o^_^)o o(^_^)^ o(^_^o) -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
Why do you want to post it to itself? Why not use a session instead? -I dont know. Never tried session It's a lot more efficient. -OK. Is it more complicated to write? -Will Stut [EMAIL PROTECTED] kirjoitti viestissä:[EMAIL PROTECTED] William Stokes wrote: Can someone help me to get started with serializing? I think I did'nt quite understand the manual here... How to post to $PHP_SELF and read this simple array? Why do you want to post it to itself? Why not use a session instead? It's a lot more efficient. ? //print the posted array here print_r($arr_siirt_jouk); //create the array and post it in another name $arr_siirto = array(1,2,3); input type=hidden name=arr_siirt_jouk value=?php echo $arr_siirto;? ? I tried: ? //print the posted array here unserialize($arr_siirt_jouk); You need to put the unserialized array somewhere, change this to $arr_siirt_jouk = unserialize($arr_siirt_jouk); print_r($arr_siirt_jouk); //create the array and post it in another name $arr_siirto = array((serialize('1','2','3')); Here you are still putting an array into the input field. You probably want $arr_siirto = serialize(array('1','2','3')); input type=hidden name=arr_siirt_jouk value=?php echo $arr_siirto;? ? Which, to my great surprice, didn't work :) I was surpriced too! Is the manual really that poorly written? I can't see how you got to your code by following the examples provided. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
William Stokes wrote: Why do you want to post it to itself? Why not use a session instead? -I dont know. Never tried session It's a lot more efficient. -OK. Is it more complicated to write? session is great, gets me high every time. See your local supplier or go to http://php.net/session to order yours. In summary... 1) Call session_start(); at the top, that is to say the very first line, of every script 2) Use the $_SESSION superglobal at will (no pun intended) 3) PHP takes care of storing the contents of $_SESSION between pages 4) Remember that the session will expire after a period of inactivity or when the user closes their browser (subject to the configuration in php.ini - the URL above explains all that) 5) There is no step 5! -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
OK. Must try that. BTW theres something odd about my serialize. I got it return something but not quite what was expected :) Here's the result a:3:{i:0;s:1: -W Stut [EMAIL PROTECTED] kirjoitti viestissä:[EMAIL PROTECTED] William Stokes wrote: Why do you want to post it to itself? Why not use a session instead? -I dont know. Never tried session It's a lot more efficient. -OK. Is it more complicated to write? session is great, gets me high every time. See your local supplier or go to http://php.net/session to order yours. In summary... 1) Call session_start(); at the top, that is to say the very first line, of every script 2) Use the $_SESSION superglobal at will (no pun intended) 3) PHP takes care of storing the contents of $_SESSION between pages 4) Remember that the session will expire after a period of inactivity or when the user closes their browser (subject to the configuration in php.ini - the URL above explains all that) 5) There is no step 5! -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
William Stokes wrote: OK. Must try that. BTW theres something odd about my serialize. I got it return something but not quite what was expected :) Here's the result a:3:{i:0;s:1: You need to use htmlentities() (http://php.net/htmlentities) on the serialized data when putting it into the value attribute of the input tag. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
Is it bad just to remove the single quotes [ ' ] ? Stut [EMAIL PROTECTED] kirjoitti viestissä:[EMAIL PROTECTED] William Stokes wrote: OK. Must try that. BTW theres something odd about my serialize. I got it return something but not quite what was expected :) Here's the result a:3:{i:0;s:1: You need to use htmlentities() (http://php.net/htmlentities) on the serialized data when putting it into the value attribute of the input tag. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
William Stokes wrote: Is it bad just to remove the single quotes [ ' ] ? From what? In fact, yes, almost certainly bad. -Stut Stut [EMAIL PROTECTED] kirjoitti viestissä:[EMAIL PROTECTED] William Stokes wrote: OK. Must try that. BTW theres something odd about my serialize. I got it return something but not quite what was expected :) Here's the result a:3:{i:0;s:1: You need to use htmlentities() (http://php.net/htmlentities) on the serialized data when putting it into the value attribute of the input tag. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
From here: $arr_siirto = array((serialize('1','2','3')); after removing the single quotes it started to work. -W Stut [EMAIL PROTECTED] kirjoitti viestissä:[EMAIL PROTECTED] William Stokes wrote: Is it bad just to remove the single quotes [ ' ] ? From what? In fact, yes, almost certainly bad. -Stut Stut [EMAIL PROTECTED] kirjoitti viestissä:[EMAIL PROTECTED] William Stokes wrote: OK. Must try that. BTW theres something odd about my serialize. I got it return something but not quite what was expected :) Here's the result a:3:{i:0;s:1: You need to use htmlentities() (http://php.net/htmlentities) on the serialized data when putting it into the value attribute of the input tag. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
William Stokes wrote: From here: $arr_siirto = array((serialize('1','2','3')); after removing the single quotes it started to work. Yes, the quotes here are not needed because they're numbers. If they were not numbers then the quotes would still be needed. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
You're right. BTW, can sessions and $POST be mixed? If yes is there any reason what so ever to do that? -W Stut [EMAIL PROTECTED] kirjoitti viestissä:[EMAIL PROTECTED] William Stokes wrote: From here: $arr_siirto = array((serialize('1','2','3')); after removing the single quotes it started to work. Yes, the quotes here are not needed because they're numbers. If they were not numbers then the quotes would still be needed. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
William Stokes wrote: You're right. I'm also shocked, but only mildly. BTW, can sessions and $POST be mixed? If yes is there any reason what so ever to do that? Your question indicates that you don't understand what sessions are. Please read http://www.oreilly.com/catalog/webdbapps/chapter/ch08.html for a well-written introduction. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
True. I'm not famiar with sessions. I have always used $POST to transmit variables. -W Stut [EMAIL PROTECTED] kirjoitti viestissä:[EMAIL PROTECTED] William Stokes wrote: You're right. I'm also shocked, but only mildly. BTW, can sessions and $POST be mixed? If yes is there any reason what so ever to do that? Your question indicates that you don't understand what sessions are. Please read http://www.oreilly.com/catalog/webdbapps/chapter/ch08.html for a well-written introduction. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
So. If large amount of variables are needed to be preserved in arrays or otherwise is session the (normal)way to go? -W Stut [EMAIL PROTECTED] kirjoitti viestissä:[EMAIL PROTECTED] William Stokes wrote: You're right. I'm also shocked, but only mildly. BTW, can sessions and $POST be mixed? If yes is there any reason what so ever to do that? Your question indicates that you don't understand what sessions are. Please read http://www.oreilly.com/catalog/webdbapps/chapter/ch08.html for a well-written introduction. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
At 3:55 PM +0300 4/20/06, William Stokes wrote: BTW, can sessions and $POST be mixed? If yes is there any reason what so ever to do that? Yes, you can use sessions, post, get, and cookies all in the same script if you want. Yes, there can be reasons to do that. tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] POST arrays?
I'd try this: ?php $arr_siirto = array(1,2,3); print_r($arr_siirto); $arse = $arr_siirto; print_r($arse); Foreach($arr_siirto as $value){ echo input type=text name=\arr_siirto[]\ values='$value'; } ? And when submit do this: ? $arr_sirto = $_REQUEST['arr_siirto']; Print_r($arr_sirto); ? Regards! Edwin. -Mensaje original- De: tedd [mailto:[EMAIL PROTECTED] Enviado el: Jueves, 20 de Abril de 2006 08:28 a.m. Para: William Stokes; php-general@lists.php.net Asunto: Re: [PHP] POST arrays? At 3:55 PM +0300 4/20/06, William Stokes wrote: BTW, can sessions and $POST be mixed? If yes is there any reason what so ever to do that? Yes, you can use sessions, post, get, and cookies all in the same script if you want. Yes, there can be reasons to do that. tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
William Stokes wrote: Hello, How to post an array with associated values? This works ok ?php $arr_siirto = array(1,2,3); print_r($arr_siirto); $arse = $arr_siirto; print_r($arse); ? But if I post it to another form with this: input type=hidden name=arr_siirt_jouk value=?php echo $arse;? And print there with: print_r($arr_siirt_jouk); prints: Array So how can post the values forward? Thanks -Will Here is the answer that you are looking for. Just create multiple hidden fields $arr_siirto = array(1,2,3); foreach ($arr_siirto AS $key = $value) { echo input type=\hidden\ name=\arr_siirt_jouk[{$key}]\ value=\{$value}\\n; } Jim -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST arrays?
On Thu, April 20, 2006 5:18 am, William Stokes wrote: How to post an array with associated values? input type=hidden name=arr_siirt_jouk value=?php echo $arse;? And print there with: print_r($arr_siirt_jouk); prints: Array So how can post the values forward? http://www.php.net/manual/en/faq.html.php#faq.html.arrays -- Like Music? http://l-i-e.com/artists.htm -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST Arrays with register globals..
$groups = $_POST['groups']; or if(isset($_POST['groups']) is_array($_POST['groups'])) $groups = $_POST['groups']; else $groups = array(); so that groups is an (empty) array even if no checkboxes were checked mh. On Wed, 12 Jun 2002, Adam Plocher wrote: input type=checkbox name=groups[] value=1 checkednbsp; blah1br input type=checkbox name=groups[] value=2 checkednbps; blah2br input type=checkbox name=groups[] value=3 checkednbsp; blah3br I can't seem to access that data correctly when that form gets submitted. I have tried: $groups[] = $_POST['groups[]']; and $groups[] = $_POST['groups']; no luck.. Can somebody please give me a hand, thanks a lot. -Adam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] POST Arrays with register globals..
Hi Adam: On Wed, Jun 12, 2002 at 01:15:03PM -0700, Adam Plocher wrote: input type=checkbox name=groups[] value=3 checkednbsp; blah3br $groups[] = $_POST['groups[]']; This is just wrong. $groups[] = $_POST['groups']; This assigns the global groups array to one element in a local groups array. So, if you then do the following, you'd see something: echo $groups[0][0]; What I assume you're trying to do is create a whole new local groups array containing everything in the global gropus array. Do this: $groups = $_POST['groups']; Of course, there is really no point in your doing that though. just use $_POST['groups'][0] and you're good to go. Saves time and memory. Enjoy, --Dan -- PHP classes that make web design easier SQL Solution | Layout Solution | Form Solution sqlsolution.info | layoutsolution.info | formsolution.info T H E A N A L Y S I S A N D S O L U T I O N S C O M P A N Y 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409 -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] POST Arrays with register globals..
$_POST['groups'] is an array. It's size is going to be dependant on how many check boxes were checked. So, in your example, if only blah2 is selected, you'll have $_POST['groups'][0] == '2' You can use count($_POST['groups']) to see how many boxes were checked. ---John Holmes... -Original Message- From: Adam Plocher [mailto:[EMAIL PROTECTED]] Sent: Wednesday, June 12, 2002 4:15 PM To: [EMAIL PROTECTED] Subject: [PHP] POST Arrays with register globals.. input type=checkbox name=groups[] value=1 checkednbsp; blah1br input type=checkbox name=groups[] value=2 checkednbps; blah2br input type=checkbox name=groups[] value=3 checkednbsp; blah3br I can't seem to access that data correctly when that form gets submitted. I have tried: $groups[] = $_POST['groups[]']; and $groups[] = $_POST['groups']; no luck.. Can somebody please give me a hand, thanks a lot. -Adam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php