[eluser]PixelPanic[/eluser]
Hello
I have tried for the last two days to figure this out but just can't. I also don't know if I'm doing this correct.
I have a URL based like so
http://localhost/admin/radio/edittimetable/Tuesday/1
The last two parts are URI Segments
I make use of the HMVC Addon if you're wondering why the URL is longer than normal, but that's not the issue.
Added a screenshot of the database layout as well.
I have this function in the Controller Radio
Code:
function edittimetable()
{
if($this->uri->segment(4) == TRUE && $this->uri->segment(5) == TRUE){
$this->load->library('form_validation');
if ($this->form_validation->run() == FALSE)
{
if (!$this->db->field_exists(''.$this->uri->segment(5).'', 'timetable'))
{
redirect('/admin/radio/timetable');
}
$this->db->select(''.$this->uri->segment(5).'');
$this->db->where('day', $this->uri->segment(4));
$data['timetable'] = $this->db->get('timetable');
$get_info = $data['timetable'];
if (!$get_info->num_rows()) {
redirect('/admin/radio/timetable');
}
$data['main_content'] = 'radio/edittimetable';
$this->load->view('admin/template', $data);
}
else
{
redirect('/admin/radio/timetable'); //Testing with Redirect
}
}
else{
redirect('/admin/radio/timetable');
}
}
and the View
Code:
<?php
foreach ($timetable->result_array() as $row) {
$djslot = $row[$this->uri->segment(5)];
} ?>
<div class="container_16"> <br />
<div class="grid_9 cnt" id="left">
<h1>Dashboard - Radio</h1>
<div>
<?php echo validation_errors(); ?>
<?=form_open('admin/radio/edittimetable/' . $this->uri->segment(4). '/' . $this->uri->segment(5));?>
<h2>Radio Station TimeTable Edit</h2>
<p>Adding DJ to <?php echo''.$this->uri->segment(4).''; ?>.</p>
<p class="left">
<label>DJ Select:</label>
<input name="djslot" type="text" class="inputText" id="textfield" value="<?=''.$djslot.''?>" />
<div class="clear"></div>
<button type="submit">Submit</button>
</p>
<div class="clear"></div>
<?php echo form_close(); ?>
</div>
</div>
<div class="grid_3">
<div class="subnav">
<h3>Sub Menu</h3>
<p><?php echo anchor('/admin/radio', 'Manage Radio'); ?></p>
<p><?php echo anchor('/admin/radio/timetable', 'Manage Timetable'); ?></p>
<p><?php echo anchor('/admin/radio/info', 'Change Radio Information'); ?></p>
<p><?php echo anchor('/admin/radio/source', 'Source Kick'); ?></p>
</div>
<br />
</div>
</div>
The issue is when I press the Submit button it does not redirect to the test redirect just stays on the page. I'm not adding any stuff to the database just yet.
I have no idea what I have done wrong
Code improvements are welcomed lol!