[FX.php List] Retaining $_POST Requests in Form Redux

Dale Bengston dbengston at preservationstudio.com
Thu Mar 1 17:10:12 MST 2007


You should not need to serialize $_POST to store it in a session  
array element. Each element will be named the same as its POST  
equivalent. It's just one level deeper in an array. Given a form with  
these inputs,
	<input type="hidden" Name="first" value="this">
	<input type="hidden" name="second" value="that">

...and that you store them in a session variable like this:
$_SESSION['postvars'] = $_POST;

You have now stored the post array in an element of the $_SESSION  
array. Then you can address the individual elements like this:
	$_SESSION['postvars']['first'] //value is 'this'
	$_SESSION['postvars']['second'] //value is 'that'


Dale


On Mar 1, 2007, at 5:48 PM, Jonathan Schwartz wrote:

> I will try both this version and the serialize version.   But...
>
> What is the syntax for retrieving the desired variable from within  
> $_SESSION['postvars'] ?
>
> Normally, it would be $postValue = $_POST['postValue'];
>
> Would it be $postValue = $_SESSION['postvars']['postValue'];   ?
>
> That's just a guess.
>
> J
>
>
> At 5:17 PM -0500 3/1/07, DC wrote:
>> yes, but you can store them in a session to keep them around  
>> provided your redirect is to the same server.
>>
>> not sure if this would work, try it...
>>
>> $_SESSION['postvars'] = $_POST;
>>
>>
>> then on your next page, they should be there as:
>>
>> print_r($_SESSION['postvars']);
>>
>> dan
>>
>> Jonathan Schwartz had written:
>>> Hi Folks,
>>>
>>> I would like to perform php error checking in the same page as  
>>> the form, and then head of to the next page is no errors are  
>>> found. The problem is when I detour to top of the same page to do  
>>> the php testing, instead of heading directly to the target page,  
>>> aren't the $_POST variables lost?
>>>
>>> Would like to do both.
>>>
>>> J
>>>
>>> PSEUDO CODE:
>>> <? if(isset($_POST['summit']) {
>>>     if(errorisnotfound) {
>>>     header('Location:nextpage.php')
>>>     }
>>>     }
>>> ?>
>>>
>>> <form action='thispage.php' type ="post'>
>>> <input type="hidden" Name="2" value="this">
>>> <input type="hidden" name="1" value="that">
>>> <input type="submit" value="submit'>
>>> </form>
>>>
>>>
>>>
>>>
>> _______________________________________________
>> FX.php_List mailing list
>> FX.php_List at mail.iviking.org
>> http://www.iviking.org/mailman/listinfo/fx.php_list
>
>
> -- 
>
> Jonathan Schwartz
> FileMaker 8 Certified  Developer
> Associate Member, FileMaker Solutions Alliance
> Schwartz & Company
> jonathan at eschwartz.com
> http://www.eschwartz.com
> http://www.exit445.com
> 415-381-1852
>
> _______________________________________________
> FX.php_List mailing list
> FX.php_List at mail.iviking.org
> http://www.iviking.org/mailman/listinfo/fx.php_list



More information about the FX.php_List mailing list