passing a string in html

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

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

Re: passing a string in html

B Squared wrote:

Quoted text here. Click to load it

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       < <
                     Home is where the ~/.bashrc is

Re: passing a string in html

David Dorward wrote:

Quoted text here. Click to load it

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

Re: passing a string in html

Quoted text here. Click to load it

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 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.

Re: passing a string in html

Andy Dingley wrote:
Quoted text here. Click to load it

Point taken.

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

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

Site Timeline