我是新來的PHP。我正在嘗試按鈕提交保存表單。但是它在頁面呈現時保存表單。我試過這個。如何在按鈕中提交表單保存在php
PHP代碼
<?php
if (($this->request->server['REQUEST_METHOD'] == 'POST') && $this->validate()) {
$this->model_catalog_contactus->saveContact($this->request->post);
}
?>
HTML代碼
<form action="/common/contactus" method="post" class="smart-green">
<h2>Contact Us</h2>
<p><label><span>Name :
</span><input id="name" type="text" name="contactname" placeholder="Your Name">
</label><label><span>Email :</span>
<input id="email" type="text" name="email" placeholder="Your Email">
</label>
<label><span>Mobile :</span>
<input id="email" type="text" name="mobile" placeholder="Your Mobile Number">
</label>
<label><span>Message :</span>
<textarea rows="" cols="" placeholder="Your message here" name="message"></textarea>
</label>
<label><span> </span>
<input type="submit" class="btn btn-primary" value="save" style="margin-top:15px;" name="submit-btn"/>
</label></p>
</form>
發表您的HTML。希望它來自Opencart – ashokhein 2014-12-11 05:24:19
是的,它來自opencart和MVC框架 – 2014-12-11 05:45:55