[英]I am submitting form by using post method but i am unable to get the value from input field. How I can get the value
<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>
its my controller in codeignite code 它是我在codeignite代码中的控制器
You can update your form to persist the input values, closely see set_value
part, for more information visit HERE 您可以更新表单以保留输入值,请密切关注
set_value
部分,有关更多信息,请访问此处
<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>
Inside miner.php
file write below method miner_logins
在
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.
}
}
I haven't tested the code, but hope this will help you to learn how form submission should be handled in CI. 我尚未测试代码,但希望这将帮助您了解如何在CI中处理表单提交。
In your miner_logins
of your class miner
, you can get the values like this as below that may help you. 在您的class
miner
miner_logins
中,您可以获取如下所示的值,可能会对您有所帮助。 Always try to assign it by creating variable for better code structure. 始终尝试通过创建变量来分配它以获得更好的代码结构。
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.
}
try this 尝试这个
$var_1 = $this->input->post('demail', TRUE);
$var_2 = $this->input->post('password', TRUE);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.