mysql - 我想在用户做某事时更改我在数据库中的状态

标签 mysql codeigniter

我的应用程序中有一个需求表单,在该表单中,当用户插入需求然后提交时,我会向特定供应商发送一封电子邮件。

我想做的是,当供应商看到该要求时,我想 自动将状态从 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/

相关文章:

php - Javascript 确认删除

mysql - 在 MySQL 中使用自动递增获取最后创建的 ID

php - 从不同的表中选择用户名,其中 id 在 codeigniter 中匹配

PHP:从数组中获取数据

mysql - 使用 AES 加密的食品 Grocery

php - 使用 CodeIgniter 创建 XML

mysql - 如何进行查询(限制在 2 个年龄之间 - 存储为日期)

php - 使用复选框和文本区域数据更新 MYSQL 数据库(在 PHP 中)

php - 如何在数据库中保存为文本类型时比较日期

java - Hibernate 5.1 和 Java 8 LocalDateTime