[英]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>
任何人都可以幫助我,如有必要,可以提供指向我網站的鏈接。
感謝任何幫助:)
您是否嘗試過更改:
<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.