Reputation: 1472
I have a input field
<?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>
And in codeigniter moneyexchange controller I have a function here
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');
}
But for some reason I cannot get the value from the input field in the view file to the controller, please help.
it shows that my $userPRovidedAmount is a (bool)false value. But I need to get numbers from the input variable
Upvotes: 1
Views: 1109
Reputation: 20469
You have a link where your submit button should be. A link wont submit the form (unless there is some unseen javascript) - it will just make a regular GET
request to the page (hence why POST
is empty in your controller)
Change the action of your form and make the submit button a form element:
<?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();?>
Upvotes: 1