return values

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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'];


Re: return values says...

Quoted text here. Click to load it

In the form on B pass it as a hidden input to C.
<input type="hidden" name="x11" value="$x11">

Quoted text here. Click to load it

Yes, if you do the above.


Re: return values

Quoted text here. Click to load it

add it to session hidden input is wrong idea - some1 can change the value

Ikciu  |  gg: 718845  |  yahoo: ikciu_irsa | www:

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

Re: return values

kirke wrote:
Quoted text here. Click to load it

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.

Rik Wasmus

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:
Quoted text here. Click to load it

Re: return values

kirke wrote:
Quoted text here. Click to load it

Hidden should work, with added security risk of users changing the value in
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

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

Rik Wasmus

Site Timeline