return values

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • kirke

    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.

  • Geoff Muldoon

    #2
    Re: return values

    hinkyeol@gmail. com says...
    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">
    for exmaple, can I use following commend in C?
    >
    $x22 = (int)$_POST['x11'];
    Yes, if you do the above.

    GM

    Comment

    • .:[ ikciu ]:.

      #3
      Re: return values

      Hmm Geoff Muldoon <geoff.muldoon@ trap.gmail.comw rote:
      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();


      Comment

      • Rik

        #4
        Re: return values

        kirke wrote:
        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


        Comment

        • kirke

          #5
          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:
          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.

          Comment

          • Rik

            #6
            Re: return values

            kirke wrote:
            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_variab le'] = $var;

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

            Rik Wasmus


            Comment

            Working...