2 Replies - 971 Views - Last Post: 26 August 2008 - 03:52 AM Rate Topic: -----

#1 yuva_17raj  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 26-August 08

hidden data and retriving it again

Posted 26 August 2008 - 02:50 AM

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



   
<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

Is This A Good Question/Topic? 0
  • +

Replies To: hidden data and retriving it again

#2 kummu4help  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 4
  • View blog
  • Posts: 245
  • Joined: 05-August 08

Re: hidden data and retriving it again

Posted 26 August 2008 - 03:08 AM

Hi yuva_17raj,

u should do the following
			<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 :)
Was This Post Helpful? 0
  • +
  • -

#3 pemcconnell  Icon User is offline

  • D.I.C Regular
  • member icon

Reputation: 54
  • View blog
  • Posts: 472
  • Joined: 05-August 08

Re: hidden data and retriving it again

Posted 26 August 2008 - 03:52 AM

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:
<?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:
<?php
$myarrayfromlastpage = unserialize($_POST['test2']);
$myarrayfromlastpage = urldecode($_POST['test2']);

print_r($myarrayfromlastpage);
?>


This post has been edited by pemcconnell: 26 August 2008 - 03:57 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1