Forum Moderators: coopster

Message Too Old, No Replies

data transfer on php pages

         

frdo06

4:45 pm on Sep 13, 2006 (gmt 0)

10+ Year Member



I want to be able to pass values in the controls say textbox on a form on one page to another and back. All my pages are php files. I would also like to be able to pass some of the values through session from one page to the other. Can any one up there help with some sample codes or guidelines?

matc

5:35 pm on Sep 14, 2006 (gmt 0)

10+ Year Member



Hi,

If I'm understanding this right this post is in the wrong area but maybe try reading the info by using PHP variables $_POST or $_GET, for example with $_POST.

$pData = (isset($_POST)) $_POST;

# clean posted data
if (!empty($pData) && is_array($pData) ) {
reset($pData);
while ( list($k,$v) = each($pData) ) {
strip_tags(stripslashes(trim($k)));
strip_tags(stripslashes(trim($v)));
}

# parse key:value pairs
if (!empty($pData) && array_key_exists('key', $pdata) ) {
while ( list($k,$v) = each($pData) ) {
switch( $k ) {
case 'key': $value = $v;
# other cases for other values to extract?
break;
default:
$value = "";
break;
}
}
}

to make the contents visable in a text area


<textarea name="txt" id="txt"><?php echo $value?></textarea>

Or to hold state on session information in the background and across multiple form pages try:


<input type="hidden" name="id" id="id" value="<?php echo $value?>" />

If you are passing multiple enteries from checboxes make sure you tie it as an array, e.g.


<input type="checkbox" name="values[]" value="" />
<input type="checkbox" name="values[]" value="" />

Always be careful not to output data without cleaning it into your pages.. have a look at this to see what I mean ;) [en.wikipedia.org...]


Some of this is over the top and someone else may have a more direct way but it might prove a good place to start when considering the steps to take..

Hope it helps, matc