每次用户在codeigniter中刷新浏览器时如何停止在数据库中存储空值

M5533

我在应用程序中创建了一个表单。因此,每当用户刷新浏览器时。存储在数据库中的表单空值以及邮件也将在每次刷新浏览器时发送给特定的人。

这是我的看法:

<form action="" id="form" method="post" >

  <div class="form-group">

    <div class="form-group">
      <label>Select</label>
      <select class="form-control" name="selection">
        <option>Telephonic</option>
        <option>F2F</option>
        <option>HR</option>
      </select>
    </div>

    <div class="box-body pad">
      <label>Comments</label>
      <textarea class="textarea" name="comments"  id="Comments "placeholder="Place comments here" style="width: 100%; height: 200px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"></textarea>
    </div>

    <div class="box-body pad">
      <label>Results</label>
      <textarea class="textarea" name="results" placeholder="Place results here" style="width: 100%; height: 200px; font-size: 14px; line-height: 18px; border: 1px solid #dddddd; padding: 10px;"></textarea>
    </div>

    <div class="form-group">
      <label>
        <input type="radio" name="selection_process" value="1" class="flat-red" checked>Selected
      </label>

      <label>
        <input type="radio" name="selection_process" value="2" class="flat-red">Not Selected
      </label>
    </div>

    <div class="row">
      <div class="col-xs-8">
        <div class="checkbox icheck">

        </div>
      </div>

      <div class="col-xs-4">
        <button type="submit" name="submit" id="submit"class="btn btn-primary btn-block btn-flat">Submit</button>
      </div>
    </div>

  </div>

</form>

这是我的控制器:

<?php
public function add_selection()
{
  $data=array(
    'selection'=>$this->input->post('selection'),
    'comments'=>$this->input->post('comments'),
    'results'=>$this->input->post('results'),
    'selection_process'=>$this->input->post('selection_process')
    );

  if($data['selection_process']==1)
  {
    $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');
    $list=array('[email protected]','[email protected]');
    $this->email->to($list);
    $this->email->subject('YOU ARE SELECTED');
    $link = 'Click on this link - <a href="http://localhost/job_portal/index.php/Login/signin">Click Here</a>';
    $this->email->message($link);
    $this->email->send();
  }
  else
  {
    $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');
    $list=array('[email protected]','[email protected]','[email protected]');
    $this->email->to($list);
    $this->email->subject('YOU ARE NOT SELECTED');
    $link = 'Click on this link - <a href="http://localhost/job_portal/index.php/Login/signin">Click Here</a>';
    $this->email->message($link);
    $this->email->send();
  }
  $this->SelectionModel->add_selection_details($data);
  $this->load->view('selection/selection_details',$data);
}
?>

请帮我怎么做..谢谢..

巴拉提

这是解决方案。.像这样更改您的控制器和模型代码。

控制器:

public function add_selection()

{

$data["msg"]="";
 $this->load->model('SelectionModel');
$data['rolename']=$this->SelectionModel->getrolename();
$data['candidate']=$this->SelectionModel->getcandidates();
$data['usertype']=$this->SelectionModel->getusers();
$data['companyname']=$this->SelectionModel->getcompanyname();

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

 $this->SelectionModel->add_selection_details($this->input->post());
 $all_users = $this->input->post('user_id');
 print_r($all_users);
       foreach($all_users as $key)
      {
         $get_email = $this->SelectionModel->get_user_email_by_id($key);

         $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->cc('[email protected]'); 
          $this->email->bcc('[email protected]');
         $this->email->subject('this is our candidate details 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('selection / selection_details',$ data); }

模型:

function add_selection_details($post='')

{

  $data=array(
          'selection_id'=>$this->input->post('selection_id'),
          'comments'=>$this->input->post('comments'),
          'results'=>$this->input->post('results'),
        'role_id'=>$this->input->post('role_id'),
        'candidate_id'=>$this->input->post('candidate_id'),
         'company_id'=>$this->input->post('company_id'),
        'user_id'=> implode(',',$this->input->post('user_id'))
          // 'selection_process'=>$this->input->post('selection_process')

        );
   $this->db->insert('selection', $data);

}

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

如何在数据库中验证用户从浏览器输入的 otp?

来自分类Dev

我正在尝试将用户浏览器详细信息存储在数据库中-

来自分类Dev

在浏览器上使用php查看存储在数据库中的文件

来自分类Dev

在数据库浏览器中创建表并插入值(sqlite)

来自分类Dev

如何在数据库中存储用户兴趣

来自分类Dev

如何在数据库中存储用户兴趣

来自分类Dev

字节图像未从客户端浏览器保存在数据库中

来自分类Dev

如何在数据库中存储日期和时间(用户执行操作时存储日期)

来自分类Dev

如何从视图获取变量值到控制器方法,然后将这些值传递给模态以存储在数据库中:codeigniter

来自分类Dev

Codeigniter:如何从数组中获取数据并将其存储在数据库中

来自分类Dev

是否有可能阻止用户在laravel / javascript中关闭浏览器或在close事件之前将所有内容保存在数据库表中

来自分类Dev

如何在数据库(例如DynamoDB)中存储AWS Cognito用户池用户?

来自分类Dev

如何浏览图像形式的HTML并使用javascript将图像存储在数据库中?

来自分类Dev

用户权限存储在数据库中

来自分类Dev

Facebook用户信息存储在数据库中

来自分类Dev

在Parse数据浏览器中安全存储用户的余额

来自分类Dev

rails 在表单提交时将当前用户的电子邮件存储在数据库中

来自分类Dev

如何使用其他值中定义的类型创建值(存储在数据库中)

来自分类Dev

数据库错误-仅在某些浏览器中

来自分类Dev

Web开发:如何在浏览器中“存储”页面并防止每次浏览时都重新加载页面

来自分类Dev

如何评估浏览器中是否存在数据?

来自分类Dev

在数据库中插入数据时处理空值

来自分类Dev

您如何停止并在数据库中存储没有重复的错误消息

来自分类Dev

在 Web 表单中选中复选框时如何自动将值存储在数据库中

来自分类Dev

单选按钮值未存储在数据库中

来自分类Dev

值在数据库中存储2次

来自分类Dev

在数据库Django中存储不同的值

来自分类Dev

使用For循环将值存储在数据库中

来自分类Dev

需要加密以将值存储在数据库中

Related 相关文章

  1. 1

    如何在数据库中验证用户从浏览器输入的 otp?

  2. 2

    我正在尝试将用户浏览器详细信息存储在数据库中-

  3. 3

    在浏览器上使用php查看存储在数据库中的文件

  4. 4

    在数据库浏览器中创建表并插入值(sqlite)

  5. 5

    如何在数据库中存储用户兴趣

  6. 6

    如何在数据库中存储用户兴趣

  7. 7

    字节图像未从客户端浏览器保存在数据库中

  8. 8

    如何在数据库中存储日期和时间(用户执行操作时存储日期)

  9. 9

    如何从视图获取变量值到控制器方法,然后将这些值传递给模态以存储在数据库中:codeigniter

  10. 10

    Codeigniter:如何从数组中获取数据并将其存储在数据库中

  11. 11

    是否有可能阻止用户在laravel / javascript中关闭浏览器或在close事件之前将所有内容保存在数据库表中

  12. 12

    如何在数据库(例如DynamoDB)中存储AWS Cognito用户池用户?

  13. 13

    如何浏览图像形式的HTML并使用javascript将图像存储在数据库中?

  14. 14

    用户权限存储在数据库中

  15. 15

    Facebook用户信息存储在数据库中

  16. 16

    在Parse数据浏览器中安全存储用户的余额

  17. 17

    rails 在表单提交时将当前用户的电子邮件存储在数据库中

  18. 18

    如何使用其他值中定义的类型创建值(存储在数据库中)

  19. 19

    数据库错误-仅在某些浏览器中

  20. 20

    Web开发:如何在浏览器中“存储”页面并防止每次浏览时都重新加载页面

  21. 21

    如何评估浏览器中是否存在数据?

  22. 22

    在数据库中插入数据时处理空值

  23. 23

    您如何停止并在数据库中存储没有重复的错误消息

  24. 24

    在 Web 表单中选中复选框时如何自动将值存储在数据库中

  25. 25

    单选按钮值未存储在数据库中

  26. 26

    值在数据库中存储2次

  27. 27

    在数据库Django中存储不同的值

  28. 28

    使用For循环将值存储在数据库中

  29. 29

    需要加密以将值存储在数据库中

热门标签

归档