Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 24th, 2005, 12:55 AM
Eric
Guest
 
Posts: n/a
Default [Q] Using the POST Method with HTML Anchor Tags

I am certain the answer will be 'NO', but I wanted to ask anyway just
incase I have missed something.

Everyone knows that one pass data to a page in an anchor tag by using
the GET Method:

<a href="http://www.aaa.com/randompage.php?name=data">

What I am wondering is if there was a way to do the same thing, but use
the POST Method instead...?

My purpose in doing so is to keep the URLs the user sees clean by not
putting anything in them that they do not need to see.

This has nothing to do with security concerns as I already know there
would be ways to obtain the data being passed.

If the answer is indeed no, then what methods do people use to pass data
when there is a desire to keep the URLs clean? Cookies? Something else?



  #2  
Old July 24th, 2005, 12:55 AM
Leif K-Brooks
Guest
 
Posts: n/a
Default Re: [Q] Using the POST Method with HTML Anchor Tags

Eric wrote:[color=blue]
> <a href="http://www.aaa.com/randompage.php?name=data">
>
> What I am wondering is if there was a way to do the same thing, but use
> the POST Method instead...?
>
> My purpose in doing so is to keep the URLs the user sees clean by not
> putting anything in them that they do not need to see.[/color]

No, but there are some a couple of things I would do to make your URL
cleaner.

First of all, I would get rid of the ".php" extension. It's really an
implementation detail of how your Web site is built, and looks pretty
ugly to my tastes. Most Web servers have options that would let you use
/randompage instead of /randompage.php if configured properly.

Also, if the data you're passing is really something like a name or ID,
why not make it part of the path instead of putting it in the query
string? PHP puts extra path components in the variable
$_SERVER['PATH_INFO'] for your application to use.

So in the end, your URL would look like:

http://example.com/randompage/data
  #3  
Old July 24th, 2005, 12:55 AM
Alan J. Flavell
Guest
 
Posts: n/a
Default Re: [Q] Using the POST Method with HTML Anchor Tags

On Wed, 23 Mar 2005, Eric wrote:
[color=blue]
> Everyone knows that one pass data to a page in an anchor tag by using
> the GET Method:
>
> <a href="http://www.aaa.com/randompage.php?name=data">[/color]

Well, some of us know there's PATH_INFO in addition to
QUERY_STRING
[color=blue]
> What I am wondering is if there was a way to do the same thing, but
> use the POST Method instead...?[/color]

Are you familiar with the design aims of POST requests, vis a vis
non-idempotent requests, result cacheing, and so forth? If not, then
I'd suggest taking a step back and reviewing that topic, for some
general background.

Browsers are increasingly suppying users with protection against
accidentally re-POSTing a request, and it's a pain in the proverbials
when a significant number of browser moves - in situations where the
user feels the requests should have been idempotent - result
unnecessarily in a browser alert popping up to warn them that they
are risking re-submitting their POST request again.

So I'd suggest that you'd do better to fall into line - as far as
possible - with the general plan, rather than spotting some side issue
and letting it dominate the choice of GET versus POST.
[color=blue]
> My purpose in doing so is to keep the URLs the user sees clean by
> not putting anything in them that they do not need to see.[/color]

As another poster commented, you've already *put* something in there
that the user doesn't need to see, namely the .php

Surely -they- are providing the input for this request? So it's not
as if there's anything to hide. And maybe they'd like to bookmark the
URL, which isn't possible with a POST request (sure, you can bookmark
the /page/ which has the POST, but they still have to access that
page, feed in the data, and submit it).
[color=blue]
> This has nothing to do with security concerns as I already know
> there would be ways to obtain the data being passed.[/color]

right
[color=blue]
> If the answer is indeed no, then what methods do people use to pass data
> when there is a desire to keep the URLs clean? Cookies?[/color]

It's a possible mechanism, certainly. But some folks get annoyed by
the hail of cookies that get showered on them by some web sites, and
they finally lose patience and block the things altogether (sure, you
and I know there are more finely-divided ways of controlling them, but
users have the last word anyway). So it's best if you keep some kind
of fallback mechanism that you can use if that happens. There are
certainly some sites which use cookies for maintaining state if they
find that the user allows them, but if they can't, then you see a
random-looking string appearing in the URL instead, for the same
purpose.

(Though I did throw one site into complete confusion when one of its
advertising banners tried to hurl cookies at me, and I turned cookies
off in annoyance - which also disabled the session cookie that the
site itself had previously been using. Their server went into orbit,
redirecting to the same URL over and over until my browser called a
halt to it.)
  #4  
Old July 24th, 2005, 12:55 AM
Eric
Guest
 
Posts: n/a
Default Re: [Q] Using the POST Method with HTML Anchor Tags

Alan J. Flavell <flavell@ph.gla.ac.uk> wrote:
[color=blue]
> Are you familiar with the design aims of POST requests, vis a vis
> non-idempotent requests, result cacheing, and so forth? If not, then
> I'd suggest taking a step back and reviewing that topic, for some
> general background.[/color]

Can you provide some references?

  #5  
Old July 24th, 2005, 12:55 AM
Eric
Guest
 
Posts: n/a
Default Re: [Q] Using the POST Method with HTML Anchor Tags

Leif K-Brooks <eurleif@ecritters.biz> wrote:
[color=blue]
> Eric wrote:[color=green]
> > <a href="http://www.aaa.com/randompage.php?name=data">
> >
> > What I am wondering is if there was a way to do the same thing, but use
> > the POST Method instead...?
> >
> > My purpose in doing so is to keep the URLs the user sees clean by not
> > putting anything in them that they do not need to see.[/color]
>
> No, but there are some a couple of things I would do to make your URL
> cleaner.
>
> First of all, I would get rid of the ".php" extension. It's really an
> implementation detail of how your Web site is built, and looks pretty
> ugly to my tastes.[/color]

Interesting. I had not considered that before.
[color=blue]
> Most Web servers have options that would let you use
> /randompage instead of /randompage.php if configured properly.
>
> Also, if the data you're passing is really something like a name or ID,
> why not make it part of the path instead of putting it in the query
> string? PHP puts extra path components in the variable
> $_SERVER['PATH_INFO'] for your application to use.
>
> So in the end, your URL would look like:
>
> http://example.com/randompage/data[/color]

It could be something like a name or ID, but it could also be just about
any other random piece of data one might see being passed via the GET
Method and, perhaps, multiple pieces of data.

Also, can you provide a reference to a tutorial on how to make use of
the PATH_INFO technique?



  #6  
Old July 24th, 2005, 12:55 AM
Eric
Guest
 
Posts: n/a
Default Re: [Q] Using the POST Method with HTML Anchor Tags

Alan J. Flavell <flavell@ph.gla.ac.uk> wrote:
[color=blue][color=green]
> > If the answer is indeed no, then what methods do people use to pass data
> > when there is a desire to keep the URLs clean? Cookies?[/color]
>
> It's a possible mechanism, certainly.[/color]

So, what technique would you suggest or use in cases where it would make
sense to keep the URL looking clean?

Or, would you argue that no such case exists?
  #7  
Old July 24th, 2005, 12:55 AM
boclair
Guest
 
Posts: n/a
Default Re: [Q] Using the POST Method with HTML Anchor Tags

Eric wrote:[color=blue]
> Leif K-Brooks <eurleif@ecritters.biz> wrote:
>
>[color=green]
>>Eric wrote:
>>[color=darkred]
>>><a href="http://www.aaa.com/randompage.php?name=data">
>>>
>>>What I am wondering is if there was a way to do the same thing, but use
>>>the POST Method instead...?
>>>
>>>My purpose in doing so is to keep the URLs the user sees clean by not
>>>putting anything in them that they do not need to see.[/color]
>>
>>No, but there are some a couple of things I would do to make your URL
>>cleaner.
>>
>>First of all, I would get rid of the ".php" extension. It's really an
>>implementation detail of how your Web site is built, and looks pretty
>>ugly to my tastes.[/color]
>
>
> Interesting. I had not considered that before.
>
>[color=green]
>>Most Web servers have options that would let you use
>>/randompage instead of /randompage.php if configured properly.
>>
>>Also, if the data you're passing is really something like a name or ID,
>>why not make it part of the path instead of putting it in the query
>>string? PHP puts extra path components in the variable
>>$_SERVER['PATH_INFO'] for your application to use.
>>
>>So in the end, your URL would look like:
>>
>>http://example.com/randompage/data[/color]
>
>
> It could be something like a name or ID, but it could also be just about
> any other random piece of data one might see being passed via the GET
> Method and, perhaps, multiple pieces of data.
>
> Also, can you provide a reference to a tutorial on how to make use of
> the PATH_INFO technique?[/color]


Assuming from the above you are using PHP, here is a basic tutorial
(with an odd URL considering its purpose)
http://agachi.name/weblog/archives/2...endly-urls.htm
but this matter is better discussed on c.l.php but some quick comments
for consideration.

Exposing the string query real values in an URL can be fraught. They can
be altered maliciously in transmission. Nobody can prevent this but
contamination can be detected and the request rejected; only valid
values (or substitutes) being actioned. Google then c.l.php

Another reason to rewrite URLs is to obscurate the directory structure,
again better discussed elsewhere.

Another reason is to overcome search engines problems with the "=" in
the query string.

And the list goes on

Louise
  #8  
Old July 24th, 2005, 12:55 AM
Eric
Guest
 
Posts: n/a
Default Re: [Q] Using the POST Method with HTML Anchor Tags

boclair <boclair@boclair.com> wrote:[color=blue]
> Assuming from the above you are using PHP, here is a basic tutorial (with
> an odd URL considering its purpose)
> http://agachi.name/weblog/archives/2...mic-urls-into-
> friendly-urls.htm[/color]

Thanks for the reference. It looks quite useful and I shall have to
study it more closely.
 

Bookmarks

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles