登記後取得保存在數據庫中的一個簡單的提交用戶表單電子郵件&城市的數據,現在我需要在此窗體中添加提交數據系統後,生成用戶的地址自動電子郵件,但有提到變量i使用一個變量名爲$lang
如果用戶輸入是AR所以發送電子郵件在阿拉伯語或如果用戶輸入EN所以用英語發送電子郵件,有兩個問題我面對不知道如何解決這個電子郵件類代碼爲我分享的建議碼。笨 - 電子郵件類 - 提交
電子郵件類
public function email() {
$email = $this->input->post('email');
$city = $this->input->post('city');
$this->load->library('email');
$this->email->from('[email protected]', 'Halalat');
$this->email->to('$emai');
$this->email->subject('Halalat Newsletter Subscription');
$this->email->message('Thankyou for submission');
$this->email->send();
echo $this->email->print_debugger();
}
user.php的控制器中
<?php
if (!defined('BASEPATH'))
exit('No direct script access allowed');
class User extends CI_Controller {
function __construct() {
parent::__construct();
$this->load->helper('form');
$this->load->helper('url');
$this->load->library('user_agent');
$this->load->library('form_validation');
}
public function create_user() {
// field name, error message, validation rules
$lang = $this->input->post("lang");
$this->form_validation->set_rules('email', 'Email', 'trim|required|valid_email|is_unique[users.email]');
$this->form_validation->set_rules('city', 'City', 'trim|required');
if ($this->form_validation->run() == FALSE) {
if ($lang == "en") {
if ($this->agent->is_mobile()) {
$this->load->view('m_english_signup');
}
else
{
$this->load->view('d_english_signup');
}
} //if ($this->agent->is_mobile())
else
{
if ($this->agent->is_mobile()) {
$this->load->view('m_arabic_signup');
}
else
{
$this->load->view('d_arabic_signup');
}
}
}
else
{
$this->load->model('Users_model');
if ($query = $this->Users_model->create_member()) {
if ($lang == "en") {
if ($this->agent->is_mobile()) {
$this->load->view('m_english_thanks');
}
else
{
$this->load->view('d_english_thanks');
}
}
else
{
if ($this->agent->is_mobile()) {
$this->load->view('m_arabic_thanks');
}
else
{
$this->load->view('d_arabic_thanks');
}
}
}
}
}
}
users_model.php模型
<?php if (! defined('BASEPATH')) exit('No direct script access allowed');
class Users_model extends CI_Model
{
function create_member()
{
$new_member_insert_data = array(
'email' => $this->input->post('email'),
'city' => $this->input->post('city'),
);
$insert = $this->db->insert('users', $new_member_insert_data);
return $insert;
}//create_member
}
**有兩個問題我面對**這兩個問題是什麼? –
1-如何實現電子郵件的類和地方。 2-如何使用電子郵件類管理兩種語言輸入。 – FormaL
爲1:請參閱本http://stackoverflow.com/q/16969572/270037 –