Connecting Tech Pros Worldwide Help | Site Map

return values

kirke
Guest
 
Posts: n/a
#1: Oct 19 '06
Hi,

I have an idea about returning variables.

in 1st page, there's variable "x1". it's action page is B.
So, I can use "x1" in B.

$x11 = (int)$_POST['x1'];

B's action page is C

In that case, I want to use "x1" in C.
So, can I save "x1" in B and use it in C?

for exmaple, can I use following commend in C?

$x22 = (int)$_POST['x11'];

Thx.

Geoff Muldoon
Guest
 
Posts: n/a
#2: Oct 19 '06

re: return values


hinkyeol@gmail.com says...
Quote:
in 1st page, there's variable "x1". it's action page is B.
So, I can use "x1" in B.
>
$x11 = (int)$_POST['x1'];
>
B's action page is C
>
In that case, I want to use "x1" in C.
So, can I save "x1" in B and use it in C?
In the form on B pass it as a hidden input to C.
<input type="hidden" name="x11" value="$x11">
Quote:
for exmaple, can I use following commend in C?
>
$x22 = (int)$_POST['x11'];
Yes, if you do the above.

GM
.:[ ikciu ]:.
Guest
 
Posts: n/a
#3: Oct 19 '06

re: return values


Hmm Geoff Muldoon <geoff.muldoon@trap.gmail.comwrote:
Quote:
hinkyeol@gmail.com says...
In the form on B pass it as a hidden input to C.
<input type="hidden" name="x11" value="$x11">
add it to session hidden input is wrong idea - some1 can change the value


--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Ikciu | gg: 718845 | yahoo: ikciu_irsa | www: www.e-irsa.pl

2be || !2be $this =mysql_query();


Rik
Guest
 
Posts: n/a
#4: Oct 19 '06

re: return values


kirke wrote:
Quote:
Hi,
>
I have an idea about returning variables.
>
in 1st page, there's variable "x1". it's action page is B.
So, I can use "x1" in B.
>
$x11 = (int)$_POST['x1'];
>
B's action page is C
>
In that case, I want to use "x1" in C.
So, can I save "x1" in B and use it in C?
>
for exmaple, can I use following commend in C?
>
$x22 = (int)$_POST['x11'];
Propagating the values should not be a problem. The question is how. What
is 'B', what is 'C'?

On in include, you won't have to worry about this, it will be automatically
available. On a different request (page change), you'll have to propagate
the value by either a session, or a POST or GET variable.

Be warned to never trust POST or GET variables before extensive validation.
--
Grtz,

Rik Wasmus


kirke
Guest
 
Posts: n/a
#5: Oct 24 '06

re: return values


Thx Rik.

B, C, D are different pages. Then How can I set it?
Hidden doesn't work at all.


kirke wrote:
Quote:
Hi,
>
I have an idea about returning variables.
>
in 1st page, there's variable "x1". it's action page is B.
So, I can use "x1" in B.
>
$x11 = (int)$_POST['x1'];
>
B's action page is C
>
In that case, I want to use "x1" in C.
So, can I save "x1" in B and use it in C?
>
for exmaple, can I use following commend in C?
>
$x22 = (int)$_POST['x11'];
>
Thx.
Rik
Guest
 
Posts: n/a
#6: Oct 24 '06

re: return values


kirke wrote:
Quote:
Thx Rik.
>
B, C, D are different pages. Then How can I set it?
Hidden doesn't work at all.

Hidden should work, with added security risk of users changing the value in
between.
If the data is not vital/not a potential risk, you can set it by adding a
hidden value to the form, named whatever you like, and make sure the only
way the user comes to C (or D) is by the same form that holds that hidden
input.

If that doesn't work for you, you either have a flaw in your PHP or your
HTML. print_r($_POST) to see what you received on the request.

Also a possibility (that I wouldn't recommend, but it's possible) is to set
a GET value in the action of the form.

On bigger/more secure scripts, usually sessions are used.
Add session_start() to your script (BEFORE any output, even a space will
make it impossible to use), and then assign your value like
$_SESSION['name_of_variable'] = $var;

On a succesfull session_start() on the other pages, the value will now be
available.
--
Grtz,

Rik Wasmus


Closed Thread