setting _post

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • B.r.K.o.N.j.A.

    setting _post

    is there a way to set _post variables without submitting a form?

    something like

    <?php
    $_POST['var1']=123;
    ?>
    <a href="something .php">link</a>

    when user clicks on a link the something.php script can access
    $_POST['var1']

    Regards,

    Vedran


  • Andy Hassall

    #2
    Re: setting _post

    On Sat, 12 Mar 2005 23:37:19 +0100, "B.r.K.o.N.j.A. " <thebrkonja@ine t.hr>
    wrote:
    [color=blue]
    >is there a way to set _post variables without submitting a form?
    >
    >something like
    >
    ><?php
    > $_POST['var1']=123;
    >?>
    ><a href="something .php">link</a>
    >
    >when user clicks on a link the something.php script can access
    >$_POST['var1'][/color]

    No. "Clicking a link" implies "GET".

    Maybe there's a way with Javascript, submitting a method="post" form through
    an onClick handler; try comp.lang.javas cript if you want to try that
    (unreliable) method.

    --
    Andy Hassall / <andy@andyh.co. uk> / <http://www.andyh.co.uk >
    <http://www.andyhsoftwa re.co.uk/space> Space: disk usage analysis tool

    Comment

    • juglesh

      #3
      Re: setting _post


      "Andy Hassall" <andy@andyh.co. uk> wrote in message
      news:7gt631pd4s gtltkg7d3fdr5mf gms5gqvbu@4ax.c om...[color=blue]
      > On Sat, 12 Mar 2005 23:37:19 +0100, "B.r.K.o.N.j.A. " <thebrkonja@ine t.hr>
      > wrote:
      >[color=green]
      >>is there a way to set _post variables without submitting a form?[/color][/color]
      [color=blue][color=green]
      >>when user clicks on a link the something.php script can access
      >>$_POST['var1'][/color]
      >
      > No. "Clicking a link" implies "GET".
      >
      > Maybe there's a way with Javascript, submitting a method="post" form
      > through
      > an onClick handler; try comp.lang.javas cript if you want to try that
      > (unreliable) method.[/color]

      this page: http://tom.me.uk/scripting/submit.asp gives a way around the
      possibility of the user not having js, also, gives a way of doing it with
      css.

      I was wondering about this myself, thanks for reminding me.

      So, I was wondering the pros and cons of doing this. It's be a pain when
      you're trouble shooting, you wouldn't have an easy way of telling which
      variables had been sent. The user couldn't bookmark your pages(well, they
      would get the page with no variables set).

      --
      juglesh



      Comment

      • Kenneth Downs

        #4
        Re: setting _post

        B.r.K.o.N.j.A. wrote:
        [color=blue]
        > is there a way to set _post variables without submitting a form?
        >
        > something like
        >
        > <?php
        > $_POST['var1']=123;
        > ?>
        > <a href="something .php">link</a>
        >
        > when user clicks on a link the something.php script can access
        > $_POST['var1']
        >
        > Regards,
        >
        > Vedran[/color]

        It seems that what you want is for "var1" to exist and have the value 123
        when the user goes to "something.php" . Is this what you want? If so, then
        the simplest is this:

        <a href="something .php?var1=123"> link</a>

        ....and then the variable will be in $_GET instead of $_POST, but what's the
        difference?

        If you want to get more complicated, you will need javascript, which IMHO is
        actually a very good thing. In my world all of my users have this so it is
        not a problem, but in some circles that would be a problem.

        --
        Kenneth Downs
        Secure Data Software, Inc.
        (Ken)nneth@(Sec )ure(Dat)a(.com )

        Comment

        • B.r.K.o.N.j.A.

          #5
          Re: setting _post

          [color=blue]
          > ...and then the variable will be in $_GET instead of $_POST, but what's[/color]
          the[color=blue]
          > difference?[/color]

          Well, there's a limit of _GET variables length, _POST doesn't have that
          limitation (which is crucial for my choice of _POST over _GET)... well I
          think I'll use session, objects and serialization ... that ought to do the
          trick ... For what it's worth, I'm trying to make a display search result
          script which allows user to choose "page" of results to go to (links) and
          therefore I need to resend all the search words too... I'm trying to do this
          cleanly and neatly so I can reuse this script many times :)

          Regards,

          Vedran


          Comment

          Working...