0
我有一个联系表单,当它被引用时,它发送一封电子邮件并将数据作为备份添加到数据库中。Codeigniter,html电子邮件发送但变量是'未定义'
当测试我的电子邮件时,我实际上通过(woo)得到了html电子邮件,但是填充的变量并不是在视图中定义的 - 我错过了什么?
控制器
表单验证这里----
如果错误做到这一点.....
如果成功的话......
// set the response as successful
$respond['result'] = 'true';
$respond['success_message'] = $success_message;
// set field labels
$data['message'] = $message;
$data['first_name'] = $first_name;
$data['email'] = $email;
$html_email = $this->load->view('html_email', $data, true);
// send email notification
$this->load->library('email');
$this->email->from('email-address', 'Email-address');
$this->email->to('email-address-here');
$this->email->subject('subject');
$this->email->message($html_email);
$this->email->send();
echo $this->email->print_debugger();
// add contact message to the database
$this->contact_model->insert_contact_message($curr_lang, $this->input->post('first_name'), $this->input->post('email'), $this->input->post('message'));
在我的HTML电子邮件使用表建立并声明变量为:
<?=$first_name?>
<?=$email?>
<?=$message?>
我知道这是通过样式工作,但只是变量不通过。
当我看到我的错误,这是我从HTML电子邮件得到:
A PHP Error was encountered
Severity: Notice
Message: Undefined variable: message
工作就像一个魅力! Wow会记下从现在开始加载解析器库 - 谢谢! – user2212564
如果你在你的代码中做了很多这样的事情,一次加载到你的autoload.php中,并且它用于所有文件。 – SasaT
很高兴我能帮到你 – SasaT