简体   繁体   English

我通过使用post方法提交表单,但是我无法从输入字段中获取值。 我如何获得价值

[英]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.

相关问题 如果页面上有两种形式的POST方法,如何使用PHP获取输入字段的值 - how can I get the value of a input field using PHP if there are two forms on the page both of POST method 使用while循环时,如何获取每个输入文本的单独值? - How can I get the individual value of each input text when I am using a while loop? 我使用javascript提交表单但我无法在php页面中获取值 - I am submitting form using javascript but I am not able to get values in php page 为什么我不能使用get_post方法php从发布表单中获取值 - why can't i get the value from post form, with get_post method php 如何使用 GET 方法以具有值的形式传输输入数据 - how can i transfer input data in form with value using GET method 如何将单个值发布到PHP MyAdmin。 此代码似乎无效。 我正在尝试从表单获取值到数据库 - How do I post a single value to PHP MyAdmin. This code doesn't seem to work. I am trying to get a value from a form into a database jQuery表单提交帖子无法正常运行。 <form> 我没有使用Get方法 - jquery form submission post not woking . <form> i am not using the Get method 我在提交时从输入字段中获得 null 值 - I am getting null value from input field on submit 在Codeigniter中以Ajax提交表单,我未从成功消息中获得价值 - submitting form in ajax in codeigniter, i am not getting value in success message 这是从服务器获得的响应。 我正在尝试获取属性 Folio ID 的值。 我们怎样才能使用 PHP - This is the response getting from a server. I am trying get value of an atribute Folio ID. How can we get using PHP
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM