繁体   English   中英

HTML PHP联系人表单-提交按钮不起作用? 还是PHP问题?

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

希望您能提供帮助,我正在尝试为我的网站创建一个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>

任何人都可以帮助我,如有必要,可以提供指向我网站的链接。

感谢任何帮助:)

您应该使用Submit作为按钮类型

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

小提琴演示

查看更新的FIDDLE

您是否尝试过更改:

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

至:

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

或者,您可以使用:

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

现在, input type='button'不是用于表单提交的有效元素。 对于有效的表单元素, MDN上有一篇不错的文章 -请参见输入按钮部分

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>

在这种情况下,我同意建议的解决方案re: type="submit

但是我到达这里是由于我的按钮突然停止工作,尽管“选择”提交仍在工作。 这是由于某些Javascript中的一个小错误导致提交被终止。

只是其他检查。

试试这个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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM