CodeIgniter Forums

Full Version: cannot get post values from input item
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
input item
**********
<input type="number" min="0" max="999" 
  name="cnt" value="0"   
  onkeyup="sum('.$row['id'].');"></td>';

code
****
$this->load->library('form_validation');
  $this->load->library('session'); 
  $this->load->helper('url'); 
  $this->form_validation->set_rules('cnt','cnt');
      $cnt = $this->input->post('cnt');
      echo $cnt;

it returns 0;
Does the form have <form method="POST"> set properly?
Would be nice if they showed all the form code.
(08-23-2018, 08:38 AM)InsiteFX Wrote: [ -> ]Would be nice if they showed all the form code.

file attached.
Hi there

buttons seems to missing type="submit"

Code:
 <button type="submit" class="w3-btn w3-black" name="saveandexit">Save and Exit</button>
 <button type="submit" class="w3-btn w3-teal" name="saveandcontinue">Save and Continue</button>


hope this helps
(08-24-2018, 12:24 AM)Marcel Wrote: [ -> ]Hi there

buttons seems to missing type="submit"

Code:
 <button type="submit" class="w3-btn w3-black" name="saveandexit">Save and Exit</button>
 <button type="submit" class="w3-btn w3-teal" name="saveandcontinue">Save and Continue</button>


hope this helps
not able to get it.
(08-24-2018, 12:33 AM)kvanaraj Wrote: [ -> ]
(08-24-2018, 12:24 AM)Marcel Wrote: [ -> ]Hi there

buttons seems to missing type="submit"

Code:
 <button type="submit" class="w3-btn w3-black" name="saveandexit">Save and Exit</button>
 <button type="submit" class="w3-btn w3-teal" name="saveandcontinue">Save and Continue</button>


hope this helps
not able to get it.

can i see your controller ?
(08-24-2018, 12:48 AM)Marcel Wrote: [ -> ]
(08-24-2018, 12:33 AM)kvanaraj Wrote: [ -> ]
(08-24-2018, 12:24 AM)Marcel Wrote: [ -> ]Hi there

buttons seems to missing type="submit"

Code:
 <button type="submit" class="w3-btn w3-black" name="saveandexit">Save and Exit</button>
 <button type="submit" class="w3-btn w3-teal" name="saveandcontinue">Save and Continue</button>


hope this helps
not able to get it.

can i see your controller ?
public function register_insert()
{
  

if (isset($_POST['saveandcontinue']))
{
$this->load->library('form_validation');
  $this->load->library('session'); 
  $this->load->helper('url'); 
  $this->form_validation->set_rules('india','india');
      $cnt = $this->input->post('india');
      echo $cnt;
(08-24-2018, 12:52 AM)kvanaraj Wrote: [ -> ]
(08-24-2018, 12:48 AM)Marcel Wrote: [ -> ]
(08-24-2018, 12:33 AM)kvanaraj Wrote: [ -> ]
(08-24-2018, 12:24 AM)Marcel Wrote: [ -> ]Hi there

buttons seems to missing type="submit"

Code:
 <button type="submit" class="w3-btn w3-black" name="saveandexit">Save and Exit</button>
 <button type="submit" class="w3-btn w3-teal" name="saveandcontinue">Save and Continue</button>


hope this helps
not able to get it.

can i see your controller ?
public function register_insert()
{
  

if (isset($_POST['saveandcontinue']))
{
$this->load->library('form_validation');
  $this->load->library('session'); 
  $this->load->helper('url'); 
  $this->form_validation->set_rules('india','india');
      $cnt = $this->input->post('india');
      echo $cnt;

I think you really need to read through the documentation on CI site theres alot of help there.
stack overflow is really helpfull as well.

I use the controller to catch the input request

Code:
if ($this->input->post('sumitbutton'))
{
$this->load->model('mymodel');
$this->mymodel->mymodelfunction();
}

in the model i would get the input values(checkbox, input,dropdowns etc..)
mymodel looks somthing like this
Code:
function mymodelfunction()
{
$this->load->library('form_validation');
   // for example purposes
   $user_id = 1;  
// Set validation rules.

$validation_rules = array(
array('field' => 'save_first_name', 'label' => 'First Name', 'rules' => 'required'),
array('field' => 'save_last_name', 'label' => 'Last Name', 'rules' => 'required'),
);

   
   $this->form_validation->set_rules($validation_rules);

// Run the validation.
if ($this->form_validation->run())
{

   // handle my database insert update etc here
}
else
{
// If validation fails Set validation errors.
$result = validation_errors('<p class="error_msg">', '</p>');


}
   return $result;
}


This is just some guidelines on how i go about it, hard really to help out more without complete look at what you doing.
Turn on logs in the config can also come in handy (creates a log file in logs folder).
There are different logging possibilities.

| 0 = Disables logging, Error logging TURNED OFF
| 1 = Error Messages (including PHP errors)
| 2 = Debug Messages
| 3 = Informational Messages
| 4 = All Messages

$config['log_threshold'] = 4;

good luck