How to use the submit button in HTML forms?

Submit button automatically submits a form on click. Using HTML forms, you can easily take user input. The <form> tag is used to get user input, by adding the form elements. Different types of form elements include text input, radio button input, submit button, etc.

Let’s learn about how to use the submit button in HTML forms. It is also created using HTML <input> tag but type attribute is set to button.

You can try to run the following code to use submit button to submit and reset a form. Under the action, attribute add the file, where you want to reach after clicking Submit button. Using get and post method, you can send the values to the PHP file added in action attribute.


Live Demo

<!DOCTYPE html>
      <form action="/new.php">
         Student Name:<br>
         <input type="text" name="sname">
         Student Subject:<br>
         <input type="text" name="ssubject">
         <input type="submit" value="Submit">
         <input type="reset" value="Reset">