Pass values from form using URL

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

    #1

    Pass values from form using URL

    I am creating a search box that the user types a value in, and then
    this gets passed to another page called search.php

    I would like to be able to pass these values through the URL, but I
    cant seem to figure out how. Right Now I have a simple html form that
    passes the value through posting, which I can then pull with a
    $_POST['name']. But I need to have this value be passed through URL.

  • chsadaki@hotmail.com

    #2
    Re: Pass values from form using URL


    drec wrote:[color=blue]
    > I am creating a search box that the user types a value in, and then
    > this gets passed to another page called search.php
    >
    > I would like to be able to pass these values through the URL, but I
    > cant seem to figure out how. Right Now I have a simple html form that
    > passes the value through posting, which I can then pull with a
    > $_POST['name']. But I need to have this value be passed through URL.[/color]

    Hello Drec
    Your problem can be solved by replacing the $_POST with $_GET['name']
    I guess that the value of method in the form tag is :
    <form .... method="POST".. ..>
    so u have to replace it with method="get" in this case u can see what u
    r passing in the url.

    Chamirame Sadaki

    Comment

    • Krustov

      #3
      Re: Pass values from form using URL

      <comp.lang.ph p>
      <drec>
      <27 Jun 2006 07:10:55 -0700>
      <1151417455.255 864.310160@m73g 2000cwd.googleg roups.com>
      [color=blue]
      > I am creating a search box that the user types a value in, and then
      > this gets passed to another page called search.php
      >
      > I would like to be able to pass these values through the URL, but I
      > cant seem to figure out how. Right Now I have a simple html form that
      > passes the value through posting, which I can then pull with a
      > $_POST['name']. But I need to have this value be passed through URL.
      >[/color]

      $_REQUEST['name']
      $_REQUEST['demo']
      $_REQUEST['blah']

      whatever.php?na me=ONE&demo=TWO &blah=THREE


      --

      Comment

      • Jerry Stuckle

        #4
        Re: Pass values from form using URL

        drec wrote:[color=blue]
        > I am creating a search box that the user types a value in, and then
        > this gets passed to another page called search.php
        >
        > I would like to be able to pass these values through the URL, but I
        > cant seem to figure out how. Right Now I have a simple html form that
        > passes the value through posting, which I can then pull with a
        > $_POST['name']. But I need to have this value be passed through URL.
        >[/color]

        If you want to pass them onto another URL, there are several ways of doing it.

        If, for instance, the URL accepts GET variables, you can just do

        header('www.exa mple.com?name=' . "$_POST['name']).

        If you must pass them as $POST variables, you could build a form with them as
        hidden fields, send the page to the browser and with javascript immediately
        submit the page. But depending on the user's browser, this might cause an
        unwanted flask in the window. Additionally, it depends on the user having
        javascript turned on.

        A better (but more a little more complicated) way is to user Curl to submit the
        values to the new page.

        The most complicated (but doesn't depend on outside libraries) would be to open
        a socket to the new site, send the HTTP headers, fetch the response and send it
        to the user's browser.

        --
        =============== ===
        Remove the "x" from my email address
        Jerry Stuckle
        JDS Computer Training Corp.
        jstucklex@attgl obal.net
        =============== ===

        Comment

        Working...