所以我用谷歌搜索了我的问题,但没有找到答案。
我有一个带有表格的页面。表格很简单,客户需要输入他的姓名和电话号码。提交表格后,我的控制器通过电子邮件发送客户的姓名和电话号码。
表单提交后,页面出现“您的消息发送成功!” 消息,但它出现在页面顶部,并且某些 .css 样式被覆盖。
那么,如何在提交后完全清除页面的内容,并用其他内容填充页面?表格
<form action="<?php echo $action; ?>" method="post" name="orderForm">
<input type="hidden" name="product_model" value="<?php echo $product_model; ?>">
<table>
<tr>
<td class="right">Ваше имя:</td>
<td><input type="text" name="your_name"></td>
</tr>
<tr>
<td class="right">Номер телефона:</td>
<td><input type="text" name="email"></td>
</tr>
<tr>
<td></td>
<td class="left"><input type="submit" value="ЗАКАЗАТЬ"></td>
</tr>
</table>
</form>
控制器
<?php
class ControllerCommonOrderForm extends Controller {
public function index() {
$this->document->setTitle($this->config->get('config_title'));
$this->document->setDescription($this->config->get('config_meta_description'));
$this->data['action'] = $this->url->link('common/orderForm');
$this->data['heading_title'] = $this->config->get('config_title');
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/common/orderForm.tpl')) {
$this->template = $this->config->get('config_template') . '/template/common/orderForm.tpl';
} else {
$this->template = 'default/template/common/orderForm.tpl';
}
$this->response->setOutput($this->render());
/* Check if form has been submitted */
if( isset($_POST['your_name']) )
{
/* Input data check */
$your_name = htmlspecialchars($_POST["your_name"]);
$email = htmlspecialchars($_POST["email"]);
$product_model = htmlspecialchars($_POST["product_model"]);
/* Set the e-mail recipient */
$myemail = "imakenza@yandex.ru";
/* Create a new variable by assigning a value to it */
$message_to_myemail = "Хозяин, тут заказ пришел.";
/* Send a message using the mail () function */
$from = "Имя клиента: $your_name \r\nТелефон клиента: $email \r\n Модель продукта: $product_model \r\n";
mail($myemail, $message_to_myemail, $from);
?>
<p>Your message has been successfully sent!</p>
<?php
}
}
}
?>
感谢您的关注。