Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

what do <form action=“.”>

I have a basic question. I cannot find an explanation of form action="." despite searching for on google, www.w3schools.com, etc...

Anyone know what the . action means for forms? Is it specific to Django? Bootstrap?

Code below:

{% extends "Blog.html" %}
{% block blog%}
  <h1>Create an account</h1>
  <p>Please, sign up using the following form:</p>
  <form action="." method="post">
    {{ user_form.as_p }}
    {% csrf_token %}
    <p><input type="submit" value="Create my account"></p>
  </form>
{% endblock %}
like image 676
Gilles Criton Avatar asked Feb 11 '19 16:02

Gilles Criton


People also ask

What do form actions do?

Definition and Usage. The formaction attribute specifies the URL of the file that will process the input control when the form is submitted. The formaction attribute overrides the action attribute of the <form> element.

What do you put in form action?

The HTML form action attribute defines what should happen to data when a form is submitted on a web page. The value of the action attribute should be the URL of the web resource that will process the contents of the form.

What should I put in a form action attribute?

The HTML | action Attribute is used to specify where the formdata is to be sent to the server after submission of the form. It can be used in the <form> element. Attribute Values: URL: It is used to specify the URL of the document where the data to be sent after the submission of the form.

What does form do in HTML?

An HTML form is used to collect user input. The user input is most often sent to a server for processing.


2 Answers

Form Action attribute specifies where to send the form-data when a form is submitted

Possible accepted values:

  1. An absolute URL: points to another web site (like action="http://www.example.com/example.htm")
  2. A relative URL - points to a file within a web site (like action="example.htm")

in your case of action="." you are pointing to current url/file/directory. So it will reload the same page on form submission.

like image 154
nircraft Avatar answered Oct 25 '22 14:10

nircraft


Normally, the action attribute in a form specifies where the data should go to, for example a processing file: action="proces.php".

Sometimes, action="#" or action="." is used to reload the page and process the data on the same page.

Basically, it just submits the form to the same page.

like image 43
rpm192 Avatar answered Oct 25 '22 15:10

rpm192