I have been trying to make a POST call in Codeigniter for past 3 days but unable to get POST Data.
I initially had it in table format, but on exploring, I found that getting input fields from table in CodeIgniter has posed many errors. SO today I tried it with normal input elements. I am still unable to retrieve the POST data.
Page URL formed : http://localhost/myproject/set-schedule
Form :
<?= form_open('set-schedule') ?>
<div class="form-group">
<label>Select Date: </label>
<?php
$formData = "";
if(isset($_GET['date'])) {
$formData = $this->schedule_model->get_data($_GET['date']);
echo "<input type=\"text\" class=\"date-picker\" id=\"add_date\" value=" . $_GET['date'] ."></input>";
} else {
echo "<input type=\"text\" class=\"date-picker\" id=\"add_date\"></input>";
}
?>
</div>
<div class="div-table">
<div class="div-table-row">
<div class="div-table-col heading" align="center">DATE</div>
<div class="div-table-col heading">Head1</div>
<div class="div-table-col heading">Head2</div>
<div class="div-table-col heading">Head3</div>
<div class="div-table-col heading">Head4</div>
</div>
<?php for ($row = 1; $row <= 7; $row ++) { ?>
<div class="div-table-row" id="form_data_custom">
<div class="div-table-col" align="center">
<?php echo "<input type='text' class='form-group' name='date_" . $row . "' placeholder='Enter DATE' readonly></input>"; ?>
</div>
<div class="div-table-col" align="center">
<?php echo "<input type='text' class='form-group' name='a_" . $row . "' placeholder='Enter Entry A'></input>"; ?>
</div>
<div class="div-table-col" align="center">
<?php echo "<input type='text' class='form-group' name='b_" . $row . "' placeholder='Enter Entry B'></input>"; ?>
</div>
<div class="div-table-col" align="center">
<?php echo "<input type='text' class='form-group' name='c_" . $row . "' placeholder='Enter Entry C'></input>"; ?>
</div>
<div class="div-table-col" align="center">
<?php echo "<input type='text' class='form-group' name='d_" . $row . "' placeholder='Enter Entry D'></input>"; ?>
</div>
</div>
<?php } ?>
</div>
<div class="form-group text-right">
<input type="submit" class="form-group btn btn-primary btn-sm" value="Submit"> Add/Update
</input>
</div>
</form>
Routes :
$route['set-schedule'] = 'schedule/set';
Controller (schedule.php):
public function set()
{
var_dump('HERE');
// create the data object
$data = new stdClass();
// load form helper and validation library
$this->load->helper('form');
$this->load->library('form_validation');
$form_data = $this->input->post();
echo json_encode($_POST);
echo json_encode("----");
echo json_encode($form_data);
........
}
Getting all POST Data as NULL
Please guide on where I might be going wrong. Thanks