[英]HTML PHP Contact Form - Submit Button Not Working? Or PHP Issue?
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. 希望您能提供帮助,我正在尝试为我的网站创建一个HTML格式的联系表单,该表单使用CSS样式,并使用PHP发送电子邮件。
<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="button" value="Submit Form" />
</label>
</form>
Anyone help me out, can provide the link to my site if necessary. 任何人都可以帮助我,如有必要,可以提供指向我网站的链接。
Appreciate any help :) 感谢任何帮助:)
You should use submit as the button type 您应该使用Submit作为按钮类型
<input id="button" type="submit" value="Submit Form" />
See updated FIDDLE 查看更新的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. 现在,
input type='button'
不是用于表单提交的有效元素。 For valid form elements, MDN have a great article - see the sections input and buttons 对于有效的表单元素, MDN上有一篇不错的文章 -请参见输入和按钮部分
Change type="button" to type="submit" 将type =“ button”更改为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>
In this particular case, I agree with the suggested solutions re: type="submit
. 在这种情况下,我同意建议的解决方案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.
这是由于某些Javascript中的一个小错误导致提交被终止。
Just something else to check. 只是其他检查。
try this html form 试试这个HTML表格
<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>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.