Welcome Guest, Not a member yet? Register   Sign In
[Solved] Post data NULL - Have no idea why

(This post was last modified: 06-25-2020, 10:55 AM by jreklund.)

Hi, I am working on an application for Social Workers in a Non-Profit. I am fairly new to Codeigniter, but have written apps previously.

I am starting to think that I have an install problem with this app and would like your help.

My View
PHP Code:
<div class="row">
  <div class="col-md-12">
    <p>Below is a list of Clients belonging to Funda NenjaTheir details are in summaryYou can get more details by clicking the more button, or you can edit the client by clicking edit </p>
    <class="btn btn-primary btn" href="<?php echo base_url('database/human'); ?>" role="button">
      << Back</a> <br /><br /><br />
      <form method="post" action="<?php echo base_url('database/human_form_add_val'); ?>" >
if($this->uri->segment(2) == "inserted"
        echo "<p class='text-success'>Data Inserted</p>";
        <div class="row">
          <div id='form-group' class='col'>
            <input type="text" class="form-control" id="fname" placeholder="Enter First Name"><br />
            <span class="text-danger"><?php echo form_error("fname"); ?></span>
            <input type="text" class="form-control" id="mnames" placeholder="Enter Middel Names"><br />
            <span class="text-danger"><?php echo form_error("mnames"); ?></span>
            <input type="text" class="form-control" id="lname" placeholder="Enter Surname"><br />
            <span class="text-danger"><?php echo form_error("lname"); ?></span>
            <input type="text" class="form-control" id="id_num" placeholder="Enter ID Number"><br />
            <span class="text-danger"><?php echo form_error("id_num"); ?></span>
          <div id='form-group' class='col'>
            <input type="text" class="form-control" id="address" placeholder="Enter address in one line"><br />
            <span class="text-danger"><?php echo form_error("address"); ?></span>
            <input type="text" class="form-control" id="gps_loc" placeholder="Enter GPS coordinates"><br />
            <span class="text-danger"><?php echo form_error("gps_loc"); ?></span>
            <input type="text" class="form-control" id="t_num" placeholder="Enter Telephone Number"><br />
            <span class="text-danger"><?php echo form_error("t_num"); ?></span>
            <input type="text" class="form-control" id="contact_name" placeholder="Enter Telephone Contact Name"><br />
            <span class="text-danger"><?php echo form_error("contact_name"); ?></span>
        <input class="btn btn-primary btn-lg btn-block" name="insert" type="submit" value="Submit">



My Model
PHP Code:
('BASEPATH') or exit('No direct script access allowed');

Client_list extends CI_Model

        public function __construct()
function get_doc()
                $query $this->db->get();
                return $query;

        function insert_client($data)


My Controller
PHP Code:
    public function human_form_add_val()

/* ============================================================= */
        /* ============================================================= */

        /* Set the page title here */
$data['page_name'] = 'Something went Wrong';

/* Get the Header Elements */

/* Get the Header Elements */

/* Get the Navigation */

/* Open the body section */

/* Display the title of the page as a headline */

$this->form_validation->set_rules("fname"'First Name''alpha');
$this->form_validation->set_rules("mnames"'Middle Names''alpha');
$this->form_validation->set_rules("lname"'Last Name''alpha');
$this->form_validation->set_rules("id_num"'ID Number''numeric');
$this->form_validation->set_rules("gps_loc"'GPS Location''alpha_numeric');
$this->form_validation->set_rules("t_num"'Telephone Number''numeric');
$this->form_validation->set_rules("contact_name"'Phone Contact Name''alpha');
$data = array(
"fname"            => $this->input->post("fname"),
"mnames"        => $this->input->post("mnames"),
"lname"            => $this->input->post("lname"),
"id_num"        => $this->input->post("id_num"),
"address"        => $this->input->post("address"),
"gps_loc"        => $this->input->post("gps_loc"),
"t_num"            => $this->input->post("t_num"),
"contact_name"    => $this->input->post("contact_name")

/* Finish the page with the footer */

When I submit the form, all post data is NULL as detailed below:
INSERT INTO `client` (`fname`, `mnames`, `lname`, `id_num`, `address`, `gps_loc`, `t_num`, `contact_name`) VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL)

What am I doing wrong?

This have been solved in CodeIgniter Slack channel. Missing name="" fields on all input fields.

Theme © iAndrew 2016 - Forum software by © MyBB