forms - 在codeigniter中提交表单后查看同一页面
问题描述
嗨,我正在使用表单提交,但我希望即使在提交表单后我也想显示联系页面。我不想查看错误或成功页面
这是我的控制器:
public function validate()
{
$name = $this->input->post("name");
$email =$this->input->post("email");
$captcha =$this->input->post("captcha");
$message =$this->input->post("message");
$captcha_code =$this->session->userdata("captcha_code");
if($captcha == $captcha_code){
$this->load->library("PHPMailer_Library");
$objMail = $this->phpmailer_library->load();
$mail = new PHPMailer(true);
try {
$mail->SMTPDebug = 2;
$mail->isSMTP();
$mail->Host = 'smtp.gmail.com';
$mail->SMTPAuth = true;
$mail->Username = 'proxyemu19@gmail.com';
$mail->Password = '****';
$mail->SMTPSecure = 'tls';
$mail->Port = 587;
$mail->SMTPOptions = array(
'ssl' => array(
'verify_peer' => false,
'verify_peer_name' => false,
'allow_self_signed' => true
)
);
$mail->setFrom('proxyemu19@gmail.com');
$mail->addAddress('cugurel7@gmail.com');
$mail->isHTML(true);
$mail->Subject = 'Ziyaretçi Form Mesajı';
$mail->Body ="Ziyaretçi ismi: ". $name."<br>Ziyaretçi mail adresi ".$email."<br> Ziyaretçi e-posta: ".$message;
$mail->AltBody = strip_tags($message);
$mail->send();
echo 'Message has been sent';
} catch (Exception $e)
{
echo 'Message could not be sent. Mailer Error: ', $mail->ErrorInfo;
}
}else{
echo "Doğrulama kodu yanlıştır";
}
}
你能帮我吗,我该怎么做。我的联系页面 yerel/yansayfa/contact。我想在提交后显示这个。
谢谢!!!
解决方案
您可以redirect()
在控制器上使用或制作功能,并在完成进度后调用它们
例如:
public function validate(){
.
.
.
if($mail->send();){
$this->next_function();
}else{
echo 'ops';
}
.
.
.
}
public function next_function(){
$this->load->view('name');
}
推荐阅读
- python - Scrapy:无法将项目加载到蜘蛛
- flutter - 如何在颤动中使用“SingleChildScrollView”小部件在“DataTable”中应用水平和垂直滚动?
- c++ - 如何编写随机数生成器函数?
- c# - C# 参数取决于枚举值
- xml - 使用 Shell 脚本获取数组中标签的字符串值
- ruby-on-rails - rails filter 布尔属性
- c# - .Net Reactor 错误:无法更新项目的依赖项。无法确定对象“PHMateLib.DLL”的依赖关系
- python - 使用正则表达式从线性函数中提取系数
- delphi - 如何禁用 TMemo 的弹出菜单?
- php - 在 PHP 中使用 eBay 购物 API 时遇到问题(GetSingleItem 请求)