控制器未在 codeigniter 中获取输入值
Controller is not getting input value in codeigniter
我有一个输入框
<?php
echo form_open('moneyexchange/borrow_first_page'); ?>
<input id ="Amount" type="text" placeholder="Amount in €" name="writtenamount">
<a type="submit" href="<?php echo base_url();? >index.php/moneyexchange/invest_first_page">invest</a>
</form>
在 codeigniter moneyexchange 控制器中我有一个函数
public function invest_first_page(){
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->view('header');
$userProvidedAmount = $this->input->post("writtenamount");
$data = array(
'userProvidedAmount' => $userProvidedAmount
);
$this->load->view("invest_firstpage", $data);
$this->load->view('footer');
}
但是由于某种原因我无法从视图文件中的输入字段中获取值到控制器,请帮忙。
它表明我的 $userPROvidedAmount 是一个 (bool)false 值。但我需要从输入变量中获取数字
您有一个 link 提交按钮应该在的位置。 link 不会提交表单(除非有一些看不见的 javascript) - 它只会向页面发出常规 GET
请求(因此 POST
在您的页面中是空的控制器)
更改表单的操作并使提交按钮成为表单元素:
<?php echo form_open('moneyexchange/invest_first_page'); ?>
<input id ="Amount" type="text" placeholder="Amount in €" name="writtenamount"/>
<input type="submit" value="invest"/>
<?php echo form_close();?>
我有一个输入框
<?php
echo form_open('moneyexchange/borrow_first_page'); ?>
<input id ="Amount" type="text" placeholder="Amount in €" name="writtenamount">
<a type="submit" href="<?php echo base_url();? >index.php/moneyexchange/invest_first_page">invest</a>
</form>
在 codeigniter moneyexchange 控制器中我有一个函数
public function invest_first_page(){
$this->load->helper('form');
$this->load->library('form_validation');
$this->load->view('header');
$userProvidedAmount = $this->input->post("writtenamount");
$data = array(
'userProvidedAmount' => $userProvidedAmount
);
$this->load->view("invest_firstpage", $data);
$this->load->view('footer');
}
但是由于某种原因我无法从视图文件中的输入字段中获取值到控制器,请帮忙。
它表明我的 $userPROvidedAmount 是一个 (bool)false 值。但我需要从输入变量中获取数字
您有一个 link 提交按钮应该在的位置。 link 不会提交表单(除非有一些看不见的 javascript) - 它只会向页面发出常规 GET
请求(因此 POST
在您的页面中是空的控制器)
更改表单的操作并使提交按钮成为表单元素:
<?php echo form_open('moneyexchange/invest_first_page'); ?>
<input id ="Amount" type="text" placeholder="Amount in €" name="writtenamount"/>
<input type="submit" value="invest"/>
<?php echo form_close();?>