passing a string in html

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

    passing a string in html


    I'm trying to pass a string from the current html page to one I'm
    calling. I've read (in the O'Reilly text) this involves using "?",
    but there's no example. For example, given I have a standard href
    in my code

    <a href="new_page. php" (string_I_want_ to_pass)>

    What is the syntax for passing the string? The new page is html
    with some php imbedded, and I'll want to use the string I pass
    inside the php code, but that might be a separate issue. The main
    question is: How to pass a string in an href call?

    Thanks in advance.

    B Squared
    =============== =============== =============== =============== ====
    Plagiarize. V, To take the thought or style of another writer
    whom one has never, never read.
    -- Ambrose Bierce, The Devils Dictionary






  • David Dorward

    #2
    Re: passing a string in html

    B Squared wrote:
    [color=blue]
    >
    > I'm trying to pass a string from the current html page to one I'm
    > calling. I've read (in the O'Reilly text) this involves using "?",
    > but there's no example. For example, given I have a standard href
    > in my code[/color]

    Section 3.3 of the URL spec describes the format.



    You'll probably want to Form URL Encode the data since so many libraries
    exist for handling data in the format.




    --
    David Dorward <http://blog.dorward.me .uk/> <http://dorward.me.uk/>
    Home is where the ~/.bashrc is

    Comment

    • Andy Dingley

      #3
      Re: passing a string in html

      On Thu, 05 Jan 2006 13:01:07 -0800, B Squared <null@null.co m> wrote:
      [color=blue]
      >I'm trying to pass a string from the current html page to one I'm
      >calling.[/color]

      This is generally a bad idea. For one thing it's easily hackable by
      users editing the URL in transit. There used to be a lovely bug on the
      Bloomberg.com site (heavyweight financial news) where you could make
      _their_ server generate a story with any title you wished, by passing it
      in the URL. Imagine a day-traders' blog entry with a post that
      mis-represented a story "MegaPharm announce new drug" with a title "FDA
      announce enquiry into two-headed babies"

      You don't give us enough to know just what or why you're doing, but this
      is clearly a PHP problem rather than a HTML one. Making the string for
      the href URL is easy (but remember to encode awkward characters such as
      " < > & etc.) Using this string in the target page is almost as
      simple, a matter of decoding the URL parameters that any PHP primer
      should explain.

      Comment

      • Jukka K. Korpela

        #4
        Re: passing a string in html

        David Dorward wrote:
        [color=blue]
        > Section 3.3 of the URL spec describes the format.
        >
        > http://www.faqs.org/rfcs/rfc1738.html[/color]

        As a matter of principle at least, RFC 1738 should not be cited as a
        reference as regards to generic URL format (which is what we are
        discussing here). In that role, it was obsoleted in 1998 (!) by RFC
        2396, which in turn was obsoleted a year ago by RFC 3986 (STD 66), which
        is available as simple hypertext at

        Comment

        • B Squared

          #5
          Re: passing a string in html

          Andy Dingley wrote:[color=blue]
          > On Thu, 05 Jan 2006 13:01:07 -0800, B Squared <null@null.co m> wrote:
          >
          >[color=green]
          >>I'm trying to pass a string from the current html page to one I'm
          >>calling.[/color]
          >
          >
          > This is generally a bad idea. For one thing it's easily hackable by
          > users editing the URL in transit. There used to be a lovely bug on the
          > Bloomberg.com site (heavyweight financial news) where you could make
          > _their_ server generate a story with any title you wished, by passing it
          > in the URL. Imagine a day-traders' blog entry with a post that
          > mis-represented a story "MegaPharm announce new drug" with a title "FDA
          > announce enquiry into two-headed babies"[/color]

          Point taken.
          [color=blue]
          > You don't give us enough to know just what or why you're doing, but this
          > is clearly a PHP problem rather than a HTML one. Making the string for
          > the href URL is easy (but remember to encode awkward characters such as
          > " < > & etc.) Using this string in the target page is almost as
          > simple, a matter of decoding the URL parameters that any PHP primer
          > should explain.[/color]

          Here's what I'm trying to do.
          1) the user clicks on an image on the index page
          2) this in turn calls / references a page, and passes an argument (the
          string) that is uses to build a page dynamically. The argument is
          is used in PHP and MYSQL to build the contents of the dynamic page.
          3) So the problem really has two parts, a) passing the argument to the
          target page, and extracting it so can be used inside the target
          page.

          Nothing needs to be passed back. So in programming terms, this is a
          pass by value problem, if that analogy helps any.

          Thanks in advance for any help.

          B Squared


          Comment

          Working...