2017-02-17 7 views
0

私のアプリケーションでは1つの要件としています。ユーザーがrequire.andに詳細を挿入してからsubmit ...すると、メールは特定のベンダーに1つのリンクで送られます。私は、ログインページにリダイレクトページのリンク上のベンダークリック..URLの最後のinsert_idをcodeigniter

それでは、私がやりたいことは、私が最後に挿入idを持つ電子メールのリンクを送信したいます。..ここ

は私のコントローラである:

public function requirement() 

{

$data["msg"]=""; 
    $this->load->model('RequirementModel'); 
    $data['user']=$this->RequirementModel->getusers(); 
    $data['rolename']=$this->RequirementModel->getrolename(); 


if($this->input->post()) 
{ 

    $this->RequirementModel->add_requirement($this->input->post()); 
    $all_users = $this->input->post('user_id'); 
    foreach($all_users as $key) 
     { 
     $get_email = $this->RequirementModel->get_user_email_by_id($key); 
     $req_id = $this->input->post('req_id'); 
     $role_name = $this->input->post('role_name'); 
     $vacancies = $this->input->post('vacancies'); 
     $experience = $this->input->post('experience'); 
     $jd = $this->input->post('jd'); 
     $hiring_contact_name = $this->input->post('hiring_contact_name'); 
     $hiring_contact_number = $this->input->post('hiring_contact_number'); 
     $config = Array(
      'protocol' => 'smtp', 
      'smtp_host' => 'ssl://md-in-42.webhostbox.net', 
      'smtp_port' => 465, 
      'smtp_user' => '[email protected]', 
      'smtp_pass' => 'test3' 
    ); 
     $this->load->library('email',$config); 
     $this->email->set_mailtype("html"); 
     $this->email->from('[email protected]', 'bharathi'); 
     $this->email->to($get_email); 
     $this->email->subject('this is our requirements pls go through it'); 
     $link = 'Click on this link - <a href="http://localhost/job_portal/index.php/Login/signin>Click Here</a>'; 
     $this->email->message($link); 
     print_r($get_email); 
     if($this->email->send()) 
     { 

       echo "email sent"; 
      } 
      else 
      { 
       echo "email failed"; 
      } 

} 

}

の$ this - >荷重 - >図(の要求/要求 '、$データ)。

}

誰も私を助けることができる..事前に 感謝..あなたが必要なもの

+0

これは公開アクセス可能なサーバーですか? plzはあなたのログインデータを隠す – qwertzman

答えて

1

は(データベースヘルパー関数INSERT_IDである)、それが最後のインサートのIDを返します。https://www.codeigniter.com/userguide3/database/helpers.html?highlight=insert_id

RequirementModelモデルのごadd_requirement機能は非常に似INSERT_IDを返すがあります:

return $this->db->insert_id(); 

関数を呼び出すときにその値を保存してください:

$insert_id = $this->RequirementModel->add_requirement($this->input->post()); 
+0

私は私のモデルでそれを好きでした。私たちはそのリンクのinsert_idを呼び出すことができます – bharathi

+0

私はあなたがリンクに入れたい場所を正確にはわかりませんが、私はこれが何かを推測しています[OK]: '$ link = 'このリンクをクリックしてください: Pacio

+0

signin()関数が機能していないということを意味していませんか?それは与えるのですか? – Pacio