I just found out (the hard way), that when you have a HTML form with action=""
, Webkit browsers treat it differently to Firefox and Internet Explorer.
In FF and IE, these two form tags are equivalent:
<form method="post" action=""> <form method="post">
They will both submit the form back to the same page. Safari and Chrome however will send that first form to the default page (index.php, or whatever) - the second form works the same as FF/IE.
I've quickly hacked my code so that anywhere where it would normally print an empty action, it doesn't add an action attribute at all.
This seems very messy and not the best way to be doing things. Can anyone suggest a better method? Also, can anyone enlighten me about why Webkit would do such a thing?
The action attribute defines the action to be performed when the form is submitted. Usually, the form data is sent to a file on the server when the user clicks on the submit button. In the example below, the form data is sent to a file called "action_page.php".
The method attribute specifies how to send form-data (the form-data is sent to the page specified in the action attribute). The form-data can be sent as URL variables (with method="get" ) or as HTTP post transaction (with method="post" ). Notes on GET: Appends form-data into the URL in name/value pairs.
Yes, the form is required to have an action attribute in HTML4.
The Form action property in HTML DOM is used to set or return the value of the action attribute of the Form. After submission of form the action attribute called. The form data is to be sent to the server after submission of form. Syntax: It is used to return the action property.
I usually use
<form method='POST' action='?'>
This means the current URL but with no parameters.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With