Welcome Guest, Not a member yet? Register   Sign In
cannot get post values from input item
#1

(This post was last modified: 08-23-2018, 09:19 PM by kvanaraj.)

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;

Attached Files
.php   application.php (Size: 3.18 KB / Downloads: 15)
Reply
#2

Does the form have <form method="POST"> set properly?
Reply
#3

Would be nice if they showed all the form code.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#4

(08-23-2018, 08:38 AM)InsiteFX Wrote: Would be nice if they showed all the form code.

file attached.
Reply
#5

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
Reply
#6

(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.
Reply
#7

(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 ?
Reply
#8

(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;
Reply
#9

(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
Reply




Theme © iAndrew 2016 - Forum software by © MyBB