我的应用程序中有一个需求表单,在该表单中,当用户插入需求然后提交时,我会向特定供应商发送一封电子邮件。
我想做的是,当供应商看到该要求时,我想 自动将状态从 0 更改为 1。
我的代码是这样的:
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);
$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' => 'test3@clozloop.com',
'smtp_pass' => 'test3'
);
$this->load->library('email',$config);
$this->email->set_mailtype("html");
$this->email->from('test3@clozloop.com', '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->load->view('Requirements/requirements',$data);
}
我不知道该怎么做。谁能帮帮我?
最佳答案
您可以在发送给供应商的链接中将需求 ID 作为查询字符串发送。 例如-
$link = 'Click on this link -
<a href="http://localhost/job_portal/index.php/Login
/signin?requirement_id=1">Click Here</a>';
现在在您的登录功能更新需求 ID 如下 -
function signin()
{
if( isset( $_GET['requirement_id'] ) )
{
// update requirement column here
$this->db->where( array( 'requirement_id' => $_GET['requirement_id'] ) );
$this->db->update( 'requirement', array( 'status' => '1' ) );
}
// your sign in code here
}
现在每当供应商点击链接并登录特定要求的状态时都会更新。
关于mysql - 我想在用户做某事时更改我在数据库中的状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42273002/