tags:

views:

49

answers:

4
+1  Q: 

forms html action

When I have a form like this:

<form method="post" action=".">

What does the "." in action stand for?

+3  A: 

The action attributes tell the form where to post the form data to.

. Stands for current directory, so I would say this posts to the default document in the current directory.

There are several notations for relative paths:

  • .. stands for parent directory
  • . stands for current directory
  • / stands for root directory if the URI starts with it
  • / stands for child directory if the URI does not start with it
Oded
Actually… `/` stands for the root directory. Only `/followedBySomething` stands for a child directory. Being picky, I know… :)
sprain
@sprain - fair enough :)
Oded
Thanks! That was what I did not understand
MacPython
I thought only `followedBySomething/` is a true child directory path, while `/followedBySomething` is a child of root directory!?
Martin
@MartinHa, you are right! I stand corrected, too :)
sprain
A: 

As @Oded said the action attribute tells where the form data will submit. In your case, the dot represents the current directory, so it doesn't submit data to any particular file which is not how it should be.

Sarfraz
A: 

Hi! The "." means that the form will be calling the default page of the current directory. It's not a common way to specify this, though.

More commonly you'll see things like those:

<form method="post" action="index.php">
<form method="post" action="/a/path/to/file.asp">
<form method="post" action="/">

The last one does something similar as the dot. It calls the default page in the root folder of your website.

sprain
A: 

Here is a good script to submit data automatically to the user. It also has an example html file that shows the action part in use correctly.

PHP Contact Form Script

s_broderick