On Jan 7, 2008, at 7:20 PM, Mary Anderson wrote:
Hi all,
I have a screen get_collection.php which is supposed to be used to
select something called 'data sets'. My database (the postgres
database is not the problem, PHP is) has an entity called 'data
series' which has a child entity called 'data sets'. The user is
first shown a list of all the data series. He selects a subset and
pushes a submit button. The database supplies the names of the
children of the selected data series, which are then displayed in
the scrolling list called 'data sets'.
My problem is getting the various screens in my application to
talk to each other. I have another screen called
edit_reference.php which is used to edit a reference with an id
re_reference_id. Midway through this screen I want to link the
reference of re_reference_id to data series and data sets chosen by
the user by following a link from edit_reference.php to
get_collection.php.
I thought I could just give re_reference_id to get_collection as
an url variable. Unfortunately, this doesn't work. Pushing the
submit button to actually select the data series of interest causes
the $_GET to be forgotten. Printing the value of re_reference_id in
a hidden inpput field -- which I thought for sure would end up in
the $_POST array when I hit the get_data_series submit button
doesn't work either.
Neither does just saying $_POST['re_reference_id'] = $re_reference_id.
Probably I should be using session variables here. But I think
they will have their own problems since they will be written on
edit_reference.php, remembered long after the call to
get_collections, and may cause trouble later.
My page is
http://www.demog.berkeley.edu/~maryfran/memdev/get_collection.php?re_reference_id=74
I am going to attach the php code and hope it makes it through.
Mary Anderson
Richard had some good directions. I'll show you how to send a variable
via GET AND POST in this basic example (which has not been tested, but
should work)...
[Some HTML Page]
<html>
...
<form action="get_collection.php?re_reference_id_get=74" method="post">
<input type="hidden" name="re_reference_id_post" value="74" />
<input type="submit" value="Go get it!" />
<input type="hidden" name="submitted" value="1" />
</form>
...
</html>
[get_collection.php]
<?php
if (isset ($_POST['submitted'])) {
echo "POST: re_reference_id = ".
$_POST['re_reference_id_post']."<br/>";
echo "GET: re_reference_id = ".$_GET['re_reference_id_get'];
echo "<pre>";
print_r ($_POST);
print_r ($_GET);
echo "</pre>";
}
?>
If you tried this previously and it didn't work, then you may have
some bigger issues with the PHP installation. Otherwise, this *should*
work. Hope this helps!
~Philip
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php