How can I pass an array to a page?

A

Anonymous

Guest
Hi,

I need to pass an array to another php page.

Please help me on how to implement the call.

Many thanks in advance.

I think the following call should be corrected somehow:
"pagetocall.php?pass=$apass"

------------- My program looks like this -----------------------------------
<?php
$apass = Array();
$apass[0]="1";
$apass[1]="2";
$apass[2]="3";
?>

<a href="pagetocall.php?pass=$apass"><img src="/images/MyImage.jpg" width="103" height="100" border="0"></a>
---------------------------------------------------------------------------------
 
that is incorrect..
?var[]=value1&var[]=value2... and so on...
 
//send array

Code:
<a href="pagetocall.php?pass=<?=rawurlencode ( serialize ( $apass ) )?>">

// next page (back to an array)

Note on most servers you will not need to do the urldecode();, because the server will do this for you, so if your server does it use this...

Code:
$pass = unserialize ( $_REQUEST['pass'] );

// we use rawurldecode so we don't decode '+' if it is in the serialized array!!!
Code:
$pass = unserialize ( rawurldecode ( $_REQUEST['pass'] ) );


jbr
 
Hi,

I tried them out with two elements in the array, and could see that correct passing values appear on url.

But when I recall them using the following syntax, I get blank values:
$pass = unserialize ( $_REQUEST['pass'] );
,or
$pass = unserialize ( rawurldecode ( $_REQUEST['pass'] ) );

$pass[0] shows blank
,and
$pass[1] shows blank


What am I mssing here?
 
$_REQUEST should be $_GET actually... as $_REQUEST is not really recommended.. it will be confusing to use $_REQUEST where you will always get data from the url
 
Back
Top