Connecting Tech Pros Worldwide Help | Site Map

return values

 
LinkBack Thread Tools Search this Thread
  #1  
Old October 19th, 2006, 01:15 AM
kirke
Guest
 
Posts: n/a
Default return values

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.


  #2  
Old October 19th, 2006, 01:25 AM
Geoff Muldoon
Guest
 
Posts: n/a
Default 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
  #3  
Old October 19th, 2006, 01:45 AM
.:[ ikciu ]:.
Guest
 
Posts: n/a
Default 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();


  #4  
Old October 19th, 2006, 03:55 AM
Rik
Guest
 
Posts: n/a
Default 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


  #5  
Old October 24th, 2006, 03:25 AM
kirke
Guest
 
Posts: n/a
Default 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.
  #6  
Old October 24th, 2006, 03:55 AM
Rik
Guest
 
Posts: n/a
Default 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


 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.