Html form not submitting data?

前端 未结 7 1968
北海茫月
北海茫月 2021-01-14 00:54

Does anyone have an idea of why my HTML form does not submit anything? Once I click the submit button it does nothing? No idea what is going on, have checked everything and

相关标签:
7条回答
  • 2021-01-14 01:28

    If your form is not submitting and you have checked the suggestions in the previous answers then its probably that you have multiple form ending tags, overlapping form tags or incorrectly closed divs.

    Here's a checklist for you which are standard and not php purely based, something you could have a look at in case you still experience this issue:

    1. Check you have a valid action element in your form tag eg: action="/subjects"

    2. Check you have a valid method element (not a type element) eg: method="post"

    3. Opening and closing <form> tags and a submit button placed within these tags. Make sure that there are no extra divs causing incorrect closing of elements. - DOUBLE CHECK THIS AS IT IS THE MOST COMMON CAUSE OF MANY HEADACHES

    4. Overlapping Form tags. (Make sure that you don't have multiple form closing tags, etc)

    5. post is being sent but there is an error in the backend/server/api which is not returning an error or success message to the browser? (Check Network section or browser after pressing F12)

    If your problem still happens then consider trying to use javascript instead of html form submission for instance. By adding an onclick event to a button and writing the form.submit function.

    I've never heard of any different form submit errors which are not logged in the console or which you can see in the Network section of your browsers development toolbar. Curious to know of your problem in the end.

    0 讨论(0)
  • 2021-01-14 01:28

    The valid attribute for the form is method not type

    method = 'post'

    0 讨论(0)
  • 2021-01-14 01:30

    Also check that your action="register.php" is not being redirected.

    For example action="/xyz/register.php" -- register.php should be in the 'xyz' folder.

    If register.php is not in the 'xyz' folder and the form is being redirected, it will go to the correct page but lose the form's values (name, email etc).

    0 讨论(0)
  • 2021-01-14 01:34

    is simple : type="POST" change with Method="POST"

    0 讨论(0)
  • 2021-01-14 01:38

    Change this line,

    <form name="register" action="register.php" id="contactForm" method="POST">
    

    you must use method="POST" instead of type="POST"

    0 讨论(0)
  • 2021-01-14 01:41

    As well as the post method, input fields should also have a name attribute.

    0 讨论(0)
提交回复
热议问题