Php 编码点火器csrf_再生
我使用csrf发布我的表单,如下所示:Php 编码点火器csrf_再生,php,codeigniter,Php,Codeigniter,我使用csrf发布我的表单,如下所示: <form action="<?php echo base_url()."lang_control/one_lang_faq_add"?>" accept-charset="UTF-8" method="post"> <div class="form-group"> <label>ВОПРОС:</label> <input class="form-contr
<form action="<?php echo base_url()."lang_control/one_lang_faq_add"?>" accept-charset="UTF-8" method="post">
<div class="form-group">
<label>ВОПРОС:</label>
<input class="form-control faq_add_quest_input" placeholder="Введите вопрос" name="faq_quest">
<input type="hidden" class="faq_add_id_input" name="lang_id">
</div>
<div class="form-group">
<label>ОТВЕТ:</label>
<input class="form-control faq_add_answer_input" placeholder="Введите ответ" name="faq_answer">
</div>
<input type="hidden" name="<?php echo $csrf['name'];?>" value="<?php echo $csrf['hash'];?>">
<button type="submit" class="btn btn-primary" >Submit</button>
</form>
我的表单动作控制方法
public function one_lang_faq_add(){
$this->load->model('one_lang_redact');
$answer = $this->input->post('faq_answer');
$quest = $this->input->post('faq_quest');
$id = $this->input->post('lang_id');
$array = array('answer'=>$answer,'quest'=>$quest,'id'=>$id);
echo $this->one_lang_redact->lang_faq_add($array);
}
“我的页面”视图控制器方法
public function __construct(){
parent::__construct();
$this->load->database();
$this->input->post(NULL, TRUE);
$this->input->get(NULL, TRUE);
$this->load->library('session');
$this->load->helper('url');
$this->load->helper('html');
$this->load->helper('form');
$this->_csrf = array(
'name' => $this->security->get_csrf_token_name(),
'hash' => $this->security->get_csrf_hash()
);
}
public function one_lang_redact($id){
$this->load->model('one_lang_redact');
$CFG =& load_class('Config', 'core');
header('Content-type: text/html; charset=' . $CFG->item('charset'));
$one_lang = $this->one_lang_redact->select_one_lang($id)->row();
$lang_faq = $this->one_lang_redact->select_lang_faq($id)->result();
$key = array("lang" => $one_lang, "lang_faq" => $lang_faq, "csrf"=>$this->_csrf);
$this->load->view('one_lang.php',$key);
}
也就是说,csrf_会再生
必须在每次post请求后更新我的csrf令牌
但这并没有发生,只有当我手动删除cookie时,令牌才会公开
帮助说明,对于每个请求后,csrf都是不同的,因此有必要这样做
请帮助我D:表单“操作”方法定义为
one'u lang\u faq\u add
,但您显示的代码是一个名为one'u lang\u faq\u redact
的方法。这是怎么回事?哦,我的承诺,但没有什么不改变,它只是发送到另一个模型,在那里被添加到数据库,我只是想知道,对于其他学生,张贴后的令牌改变,我不知道为什么。
public function __construct(){
parent::__construct();
$this->load->database();
$this->input->post(NULL, TRUE);
$this->input->get(NULL, TRUE);
$this->load->library('session');
$this->load->helper('url');
$this->load->helper('html');
$this->load->helper('form');
$this->_csrf = array(
'name' => $this->security->get_csrf_token_name(),
'hash' => $this->security->get_csrf_hash()
);
}
public function one_lang_redact($id){
$this->load->model('one_lang_redact');
$CFG =& load_class('Config', 'core');
header('Content-type: text/html; charset=' . $CFG->item('charset'));
$one_lang = $this->one_lang_redact->select_one_lang($id)->row();
$lang_faq = $this->one_lang_redact->select_lang_faq($id)->result();
$key = array("lang" => $one_lang, "lang_faq" => $lang_faq, "csrf"=>$this->_csrf);
$this->load->view('one_lang.php',$key);
}