Welcome to Dream.In.Code
Become a PHP Expert!

Join 150,174 PHP Programmers for FREE! Get instant access to thousands of PHP experts, tutorials, code snippets, and more! There are 2,218 people online right now. Registration is fast and FREE... Join Now!




hidden data and retriving it again

 
Reply to this topicStart new topic

hidden data and retriving it again

yuva_17raj
26 Aug, 2008 - 01:50 AM
Post #1

New D.I.C Head
*

Joined: 26 Aug, 2008
Posts: 1

hi i am new to PHP and i need to post the array text input box value to one form to another back and fro how can i do this here i have attached th code what i have tried



CODE
  
<table width="200" border="0" align="center">
            <tr>
              <td width="93"><div align="center" class="totval">Serial Number</div></td>
              <td width="91"><div align="center" class="totval">name</div></td>
            </tr>
            <tr>
              <td colspan="2">
              <? for($i=0;$i<10;$i++)
                 {?>
                 <table width="40%" border="0" align="center" bordercolor="#C8E2F1">
              <tr bordercolor="#C8E2F1">
                <td bordercolor="#C8E2F1" width="34%"><input type="text" name="test1[]" id="test1[]" value="<?= $i?>" ></td>
                <td bordercolor="#C8E2F1" width="66%"><input type="text" name="test2[]" id="test2[]" value="<?= $test2[$i]?>"></td>
               </tr>
          </table>
          <? }?>                              


<input type="hidden" name="test2[]" id="test2[]" value="<?= $test2?>"/>

and in second form i used the following to retrive


$testing = $_post['test2']



when i echo the above statement it is displaying simply as ARRAY not the numbers or the things i entered


so kindly suggest me a solution




User is offlineProfile CardPM
+Quote Post

kummu4help
RE: Hidden Data And Retriving It Again
26 Aug, 2008 - 02:08 AM
Post #2

D.I.C Head
Group Icon

Joined: 4 Aug, 2008
Posts: 184



Thanked: 2 times
Dream Kudos: 25
My Contributions
Hi yuva_17raj,

u should do the following
CODE

            <td bordercolor="#C8E2F1" width="34%"><input type="text" name="test1[]" id="test1[]" value="<?print $i; ?>" ></td>
                <td bordercolor="#C8E2F1" width="66%"><input type="text" name="test2[]" id="test2[]" value="<?print $test2[$i]; ?>"></td>



try it and let me know if u have any hiccups....

cheers smile.gif
User is offlineProfile CardPM
+Quote Post

pemcconnell
RE: Hidden Data And Retriving It Again
26 Aug, 2008 - 02:52 AM
Post #3

D.I.C Regular
Group Icon

Joined: 5 Aug, 2008
Posts: 403



Thanked: 38 times
Dream Kudos: 75
My Contributions
you will probibly need to use urlencode and serialize on your data before assigning it to your input value, then unserialize and urldecode to 'unwrap' it when you are retrieving it.

This will cause your data to be passed as an encrypted string, and will allow you to turn it into an array again on the next page.

e.g. First page:
CODE

<?php
$test2enc = urlencode($test2); //assuming $test2 is the array you are wanting to post
$test2enc = serialize($test2enc);
?>
<td bordercolor="#C8E2F1" width="34%"><input type="text" name="test1" id="test1" value="<?print $i; ?>" ></td>
                <td bordercolor="#C8E2F1" width="66%"><input type="text" name="test2" id="test2" value="<?print $test2enc; ?>"></td>


Second Page:
CODE

<?php
$myarrayfromlastpage = unserialize($_POST['test2']);
$myarrayfromlastpage = urldecode($_POST['test2']);

print_r($myarrayfromlastpage);
?>


This post has been edited by pemcconnell: 26 Aug, 2008 - 02:57 AM
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/9/09 03:30AM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live PHP Help!

PHP Tutorials

Reference Sheets

PHP Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month