when action =

B

Bob

then where does the output get sent? to the same page that contains
the form?

as in:
<form method="post" action="">
<input value="submit" name="submit" type="submit">
</form>

and there is no javascript on the page
 
R

Rik

then where does the output get sent? to the same page that contains
the form?

as in:
<form method="post" action="">
<input value="submit" name="submit" type="submit">
</form>

and there is no javascript on the page

Most browers default to the same page indeed. I haven't seen it in the
spec though,so if I wouldn't advise to using it like that.
 
B

Bob

Most browers default to the same page indeed. I haven't seen it in the
spec though,so if I wouldn't advise to using it like that.

Thank you. Would that be considered a sophisticated technique, or
something that a stumbling beginner would likely be to do?

The page that contains the script is a php page.
 
R

Rik

Thank you. Would that be considered a sophisticated technique, or
something that a stumbling beginner would likely be to do?

I'd say very lazy coders that trust some browser behaviour.

http://www.w3.org/TR/html4/interact/forms.html#h-17.3
"action = uri [CT]
This attribute specifies a form processing agent. User agent behavior for
a value other than an HTTP URI is undefined."
The page that contains the script is a php page.

In that case it's in most cases even easier to define the url, no matter
where you include the form:

<form method="post" action="<?php echo $_SERVER['REQUEST_URI']"; ?>">
 
J

Jonathan N. Little

Rik said:
Thank you. Would that be considered a sophisticated technique, or
something that a stumbling beginner would likely be to do?

I'd say very lazy coders that trust some browser behaviour.

http://www.w3.org/TR/html4/interact/forms.html#h-17.3
"action = uri [CT]
This attribute specifies a form processing agent. User agent behavior
for a value other than an HTTP URI is undefined."
The page that contains the script is a php page.

In that case it's in most cases even easier to define the url, no matter
where you include the form:

<form method="post" action="<?php echo $_SERVER['REQUEST_URI']"; ?>">

More typically:

<?php echo $_SERVER['PHP_SELF']; ?>

or

<?php echo 'http://' .$_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF']; ?>
 
R

Rik

Jonathan said:
Rik said:
On Mon, 12 Feb 2007 21:42:27 +0100, Rik

Most browers default to the same page indeed. I haven't seen it in
the
spec though,so if I wouldn't advise to using it like that.

Thank you. Would that be considered a sophisticated technique, or
something that a stumbling beginner would likely be to do?
I'd say very lazy coders that trust some browser behaviour.
http://www.w3.org/TR/html4/interact/forms.html#h-17.3
"action = uri [CT]
This attribute specifies a form processing agent. User agent behavior
for a value other than an HTTP URI is undefined."
The page that contains the script is a php page.
In that case it's in most cases even easier to define the url, no
matter where you include the form:
<form method="post" action="<?php echo $_SERVER['REQUEST_URI']"; ?>">

More typically:

<?php echo $_SERVER['PHP_SELF']; ?>

or

<?php echo 'http://' .$_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF']; ?>


Depends. I've had better results with the REQUEST_URI, as it's definitely
the request coming in, rather then where the user ended up after possible
rewriting etc. I'd rather the user still saw his entered URL then for
instance a whole bunch of GET variables working behind the scene.
 
J

Jonathan N. Little

Rik said:
Jonathan N. Little wrote:
More typically:

<?php echo $_SERVER['PHP_SELF']; ?>

or

<?php echo 'http://' .$_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF']; ?>


Depends. I've had better results with the REQUEST_URI, as it's
definitely the request coming in, rather then where the user ended up
after possible rewriting etc.

If rewriting is involved the final destination will be this script, no?

I'd rather the user still saw his entered
URL then for instance a whole bunch of GET variables working behind the
scene.

Well maybe if this is a GET rather than POST and you have some rewrite like:

www.example.com/script/param1/param2

www.example.com/script.php?p1=param1&p2=param2
 
R

Rik

Rik said:
Jonathan N. Little wrote:
More typically:

<?php echo $_SERVER['PHP_SELF']; ?>

or

<?php echo 'http://' .$_SERVER['SERVER_NAME'] . $_SERVER['PHP_SELF'];
?>
Depends. I've had better results with the REQUEST_URI, as it's
definitely the request coming in, rather then where the user ended up
after possible rewriting etc.

If rewriting is involved the final destination will be this script, no?

Probably, if I want the same script to handle it. It can break the
consistency of the urls/pages though. If a user arrived there with
http://example.com/path/to/script/, I'd very much like the same page to be
adressed with only that URL.
Well maybe if this is a GET rather than POST and you have some rewrite
like:

Or a combination? Most of my dynamic pages only seem to have a
/path/to/page/, but are hurled to a script in the root. Doesn't mean a
form can't post to them.

Which exactly illustrates the reason for keep REQUEST_URI in most of my
forms. I can put them almost anywhere without having to adjust anything,
and they won't break the consistency in the page-naming scheme. I normally
don't use GET's for forms either, and even if I did, it wouldn't interfere
with my normal rewrites.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,296
Latest member
HeikeHolli

Latest Threads

Top