<form class="form" method="post" action="<?php echo site_url("miner/miner_logins"); ?>">
<label>Email :</label>
<input type="text" name="demail" id="email">
<label>Password :</label>
<input type="password" name="password" id="password"> <br>enter code here
<input type="submit" name="login" id="login" value="LOG IN" class="btnlogin">
<p align="center"><a href="#">Forgot Password? Reset enter code heret via the Website</a></p>
</form>
我的控制器采用codeignite代码
答案 0 :(得分:2)
您可以更新表单以保留输入值,请仔细查看set_value
部分,有关详细信息,请访问HERE
<form class="form" method="post" action="<?php echo site_url("miner/miner_logins"); ?>">
<label>Email :</label>
<input type="text" name="demail" value="<?php echo set_value('demail'); ?> id="email">
<label>Password :</label>
<input type="password" name="password" id="password"> <br>enter code here
<input type="submit" name="login" id="login" value="LOG IN" class="btnlogin">
<p align="center"><a href="#">Forgot Password? Reset enter code heret via the Website</a></p>
</form>
在miner.php
文件内写下方法miner_logins
public function miner_logins(){
$this->load->library('form_validation');
$this->form_validation->set_rules('password', 'Password', 'required');
$this->form_validation->set_rules('demail', 'Email', 'required|valid_email');
if ($this->form_validation->run() == FALSE)
{
$this->load->view('miner_logins_view');
}else{
// set required session here and do redirection to user page.
}
}
我还没有对代码进行过测试,但希望这可以帮助您了解如何在CI中处理表单提交。
答案 1 :(得分:0)
在您班级的miner_logins
miner
中,您可以获得如下所示的值,这可能会对您有所帮助。
总是尝试通过创建变量来分配它,以获得更好的代码结构。
if($this->input->post()) // Before getting the values, check with this
{
$demail = $this->input->post('demail', TRUE);
$password = $this->input->post('password', TRUE);
echo $demail; // You will get the value of demail.
echo $password; // You will get the value of password.
}
答案 2 :(得分:0)
试试这个
$var_1 = $this->input->post('demail', TRUE);
$var_2 = $this->input->post('password', TRUE);