2014-09-24 174 views
0

我正在嘗試使用表單和PHP發送電子郵件。當我點擊發送按鈕,我得到錯誤發生錯誤:404 - 找不到。 submit.php文件與網頁位於相同的目錄中。爲什麼找不到submit.php。我的html代碼。表單操作 - 錯誤404 - 未找到

<form action="submit.php" id="form1" method="post"> 
<fieldset>    
    <label class="input">Date:<span><span><input type="text" id="datepicker" value=""/></span></span></label> 
    <label class="input">Enter Your Name:<span><span><input name="name"/></span></span></label> 
    <label class="input">Enter Your Email:<span><span><input name="email"/></span></span></label> 
    <label class="input">Subject:<span><span><input name="subject"/></span></span></label> 
    <label class="text">Enter Your Message:<span><span><textarea name="comment" cols="0" rows="0"></textarea></span></span></label> 
    <label class="input">Enter Code:<img src="php/captcha.php"><span><span><input type="text" name="vercode" /></span></span></label> 
    <label class="butt"><a href="javascript:document.getElementById('form1').reset()" class="button"><strong><b>clear</b></strong></a> 
    <a href="javascript:document.getElementById('form1').submit()" class="button"><strong><b>send</b></strong></a></label> 
</fieldset> 

+1

你有沒有關閉''? – wavemode 2014-09-24 23:36:11

回答

0

當使用<a>的使用爲形式提交按鈕,我會建議使用JavaScript函數,並把它放在錨的onclick。就像這樣:

function doSubmit(form_name) { 
 
    // check if the object exists 
 
    if (document.getElementById(form_name)) { 
 

 
    // submit the form 
 
    document.getElementById(form_name).submit(); 
 
    } 
 

 
    // prevent the link from clicking 
 
    return false; 
 
}
<a href="#" onclick="return doSubmit('form1');" class="button"><strong><b>send</b></strong></a>

同樣可以復位按鈕來完成。

通過這種方式,您絕不會將瀏覽器導航到「javascript:... etc ..」位置(不存在)。我不確定這是否屬於這種情況,但只是作爲最佳實踐建議。 :)