473,695 Members | 1,933 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

[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?

Jul 23 '05 #1
7 29849
Eric wrote:
<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.


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
Jul 23 '05 #2
On Wed, 23 Mar 2005, Eric wrote:
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">
Well, some of us know there's PATH_INFO in addition to
QUERY_STRING
What I am wondering is if there was a way to do the same thing, but
use the POST Method instead...?
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.
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.
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).
This has nothing to do with security concerns as I already know
there would be ways to obtain the data being passed.
right
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?


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.)
Jul 23 '05 #3
Alan J. Flavell <fl*****@ph.gla .ac.uk> wrote:
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.


Can you provide some references?

Jul 23 '05 #4
Leif K-Brooks <eu*****@ecritt ers.biz> wrote:
Eric wrote:
<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.
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.


Interesting. I had not considered that before.
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


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?

Jul 23 '05 #5
Alan J. Flavell <fl*****@ph.gla .ac.uk> wrote:
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?


It's a possible mechanism, certainly.


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?
Jul 23 '05 #6
Eric wrote:
Leif K-Brooks <eu*****@ecritt ers.biz> wrote:

Eric wrote:
<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.


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
implementatio n detail of how your Web site is built, and looks pretty
ugly to my tastes.

Interesting. I had not considered that before.

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

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?

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
Jul 23 '05 #7
boclair <bo*****@boclai r.com> wrote:
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


Thanks for the reference. It looks quite useful and I shall have to
study it more closely.
Jul 23 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
2715
by: laredotornado | last post by:
Hi, I'm using PHP 4 and trying to parse through HTML to look for HREF attributes of anchor tags and SRC attributes of IMG tags. Does anyone know of any libraries/freeware to help parse through HTML to find these things. Right now, I'm doing a lot of "strstr" calls, but there is probably a better way to do what I need. Thanks for any help, - Dave
4
4583
by: Nico Grubert | last post by:
Hello, I want to remove all html tags from a string "content" except <a ....>xxx</a>. My script reads like this: ### import re content = re.sub('<((|\n)*)>', '', content)
6
2919
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for this, and came across a problem that I haven't been able to solve elegantly. The problem is to find "linker" vertexes that a pair of verteces from a pre-defined set. For example, if the graph verteces represent cities and edges represent flights...
8
1776
by: lancevictor | last post by:
I'm learning javascript, and toward that end, I am recreating a page "my way". The original page: http://stenbergcollege.com and the one that I'm creating: http://www3.telus.net/neustaeter/Stenberg When I added the buttons manually, everything was hunky-dory and it looked pretty much exactly like the original page. When I changed the script so that it uses the for loop to insert the top row of buttons, space seems to get inserted...
6
3369
by: Christoph Söllner | last post by:
Hi *, is there a html parser available, which could i.e. extract all links from a given text like that: """ <a href="foo.php?param1=test">BAR<img src="none.gif"></a> <a href="foo2.php?param1=test&param2=test">BAR2</a> """ and return a set of dicts like that:
8
6012
by: Kathleen Dollard | last post by:
Hi, Oleg's answer about attribute value templates led me to look back at a different problem, and wonder if someone else had solved it. I want to output an ASP.NET page. Thus I need to output ASP.NET tags and HTML tags. <%@ Page Language= etc...
4
21836
by: Ali | last post by:
I need a functionality where my clients download Excel files and after they do, I do some processing. Downloading is easily achieved using a anchor or hyperlink tag, but that does not give me the full functionality I am after. So, I came up with a way to download the files using a stream but after I download the file and try to open it in Excel I get garbage. This is the code I use for the download function. Please help if you have any...
4
2801
by: Kevin Phifer | last post by:
Ok, before anyone freaks out, I have a solution I need to create that gathers content from maybe different places. Each one can return a <form> in the html, so its the classic can't have more than one runat=server form on a asp.net page. However, I still want developers to be able to use asp.net controls to create some apps that are created on the page. So I need multiple forms on a asp.net page(doesn't everyone). I purchased the...
15
5984
by: Francach | last post by:
Hi, I'm trying to use the Beautiful Soup package to parse through the "bookmarks.html" file which Firefox exports all your bookmarks into. I've been struggling with the documentation trying to figure out how to extract all the urls. Has anybody got a couple of longer examples using Beautiful Soup I could play around with? Thanks, Martin.
0
8652
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9140
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8867
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8841
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7688
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6511
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4599
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3025
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
1987
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.