我试图将用户的输入输入到我的电子邮件消息体中,我尝试了$data,但没有运气。我不知道该怎么做。用户输入姓名和电子邮件,点击提交会得到电子邮件,但如果我输入$data in message,结果是空的。这是控制器代码的一部分,电子邮件部分位于
//Insert the callin
public function insert_callin()
{
$data=array('name'=>$this->input->post('name'),
'email'=>$this->input->post('email'));
//print_r($data);
$result=$this->callin_model->insert_callin($data);
if($result > 0)
{
$this->session->set_flashdata('msg',"Callin Record Added Successfully");
$this->load->library('email');
$this->email->from('your@example.com', 'Your Name');
$this->email->to('donny.ortiz@nordstrom.com');
$this->email->subject('Email Test');
$this->email->message($data);
$this->email->send();
redirect('callin');
}
else
{
$this->session->set_flashdata('msg1',"Callin Record Added Failed");
redirect('callin');
}
您可以尝试下面的代码....
//Insert the callin
public function insert_callin()
{
$data=array('name'=>$this->input->post('name'),
'email'=>$this->input->post('email'));
$msg_body = "<table>";
$msg_body .= "<tr>";
$msg_body .= "<td>Name</td><td>:</td><td>".$data['name']."</td>";
$msg_body .= "<td>Email</td><td>:</td><td>".$data['email']."</td>";
$msg_body .= "</tr>";
$msg_body .= "</table>";
//print_r($data);
$result=$this->callin_model->insert_callin($data);
if($result > 0)
{
$this->session->set_flashdata('msg',"Callin Record Added Successfully");
$this->load->library('email');
$this->email->from('your@example.com', 'Your Name');
$this->email->to('donny.ortiz@nordstrom.com');
$this->email->subject('Email Test');
$this->email->message($msg_body);
$this->email->send();
redirect('callin');
}
else
{
$this->session->set_flashdata('msg1',"Callin Record Added Failed");
redirect('callin');
}
$this->email->message
接受字符串,而不是数组。
$this->email->消息接受字符串,您可以序列化数组,如$this->email->message(serialize($data));