HTML PHP Contact Form - Submit Button Not Working? Or PHP Issue?

前端 未结 5 2103
别跟我提以往
别跟我提以往 2020-12-22 06:52

Hope you can help, I am trying to knock up a contact form for my website which is HTML, styled with CSS and the email sent with PHP.

相关标签:
5条回答
  • 2020-12-22 07:06

    try this html form

    <form class="form" action="webform.php" method="post">
        <h1>Contact Form:</h1>
        <label>
        <span>Your Name:</span><input id="name" type="text" name="name" />
        </label>
    
        <label>
        <span>Email Address:</span><input id="email" type="text" name="email" />
        </label>
    
        <label>
        <span>Subject:</span><input id="subject" type="text" name="subject" />
        </label>
    
        <label>
        <span>Message</span><textarea id="feedback" name="feedback"></textarea>
        <input id="button" type="submit" value="Submit Form" />
        </label> </form>
    
    0 讨论(0)
  • 2020-12-22 07:08

    See updated FIDDLE

    Have you tried changing:

    <input id="button" type="button" value="Submit Form" />

    to:

    <input id="button" type="submit" value="Submit Form" />

    Alternatively, you can use:

    <button id="button" >Submit Form</button>

    As you have it now, input type='button' is not a valid element for form submission. For valid form elements, MDN have a great article- see the sections input and buttons

    0 讨论(0)
  • 2020-12-22 07:11

    You should use submit as the button type

    <input id="button" type="submit" value="Submit Form" />
    

    Fiddle DEMO

    0 讨论(0)
  • 2020-12-22 07:19

    In this particular case, I agree with the suggested solutions re: type="submit.

    But I arrived here due to having my buttons stop working all of a sudden, though a Select submit was still working. And it was due to a tiny bug in some Javascript that was killing the submission.

    Just something else to check.

    0 讨论(0)
  • 2020-12-22 07:24

    Change type="button" to type="submit"

    <form class="form" action="webform.php" method="post">
        <h1>Contact Form:</h1>
        <label>
        <span>Your Name:</span><input id="name" type="text" name="name" />
        </label>
    
        <label>
        <span>Email Address:</span><input id="email" type="text" name="email" />
        </label>
    
        <label>
        <span>Subject:</span><input id="subject" type="text" name="subject" />
        </label>
    
        <label>
        <span>Message</span><textarea id="feedback" name="feedback"></textarea>
        <input id="button" type="submit" value="Submit Form" />
        </label>
    </form>
    
    0 讨论(0)
提交回复
热议问题