HTML GET and POST Methods

Is it mandatory that action="abc.php" in the FORM tag must have a PHP, JSP, ASP file? Can plain HTML code display the data represented in FORM ?

In other words,

FILE: abc.html

 <form method="post" action="xyz.html"> <input type="text" name="name" id="name" value="Enter your name here" /> </form> 

OR

 <form method="get" action="xyz.html"> <input type="text" name="name" id="name" value="Enter your name here" /> </form> 

Now in the xyz.html file, is xyz.html possible to display the name entered in abc.html using only HTML code?

+6
source share
7 answers

HTML alone cannot access the provided POST / GET data. You need a server language (PHP, python, ruby, .NET, ...) to put these values โ€‹โ€‹in HTML.

Having said that, you can publish to an HTML page, you simply cannot do anything with it.

You can use JavaScript to access GET variables , but not POST.

+5
source

You cannot deal with it only with html. You must have a server side scripting language like PHP, ASP.Net or java etc.

+3
source

The purpose of using this extension on the server side is to manipulate the data sent from form elements on the server using the POST or GET method, but if you want to display the data entered in the browser, you can send it to the .html file, because they donโ€™t have to need to be manipulated.

+2
source

No, you canโ€™t. The reason for the data transfer to the server, and the server cannot process the data using simple HTML code, except for the server language such as PHP, PYTHON, JAVA, etc.

+2
source

you need a server language to process the form and receive data from the user. In PHP, at least as I know, you can leave the action = "" empty, which means that you will process the form on the same page

+2
source

Yes, you could do it with simple html + javascript. As an example, you can get http parameters using jQuery. Further information is available here:

Get Shielded URL

0
source

You can do this with the jQuery Ajax method.

 $ (document) .ready (function () {
           ajaxFunction ();
 });
     function ajaxFunction () {
         var postdata = jQuery ("# โ€‹โ€‹form"). serialize ();
         jQuery.ajax ({
             url: "xyz.html",
             type: "POST",
             data: postdata,
             success: function (response) {
                     console.log (response);
             },
             error: function () {
                 console.log (response);
             }
         });
     } 

link

0
source

All Articles