• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Form Issues

#1
[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>
    &lt;?php echo validation_errors(); ?&gt;
      &lt;?=form_open('admin/radio/edittimetable/' . $this->uri->segment(4). '/' . $this->uri->segment(5));?&gt;
      <h2>Radio Station TimeTable Edit</h2>
      <p>Adding DJ to &lt;?php echo''.$this->uri->segment(4).''; ?&gt;.</p>
      <p class="left">
        <label>DJ Select:</label>
        &lt;input name="djslot" type="text" class="inputText" id="textfield" value="&lt;?=''.$djslot.''?&gt;" /&gt;
      <div class="clear"></div>
      <button type="submit">Submit</button>
      </p>
      <div class="clear"></div>
      &lt;?php echo form_close(); ?&gt;
    </div>
  </div>
  <div class="grid_3">
    <div class="subnav">
      <h3>Sub Menu</h3>
      <p>&lt;?php echo anchor('/admin/radio', 'Manage Radio'); ?&gt;</p>
      <p>&lt;?php echo anchor('/admin/radio/timetable', 'Manage Timetable'); ?&gt;</p>
      <p>&lt;?php echo anchor('/admin/radio/info', 'Change Radio Information'); ?&gt;</p>
      <p>&lt;?php echo anchor('/admin/radio/source', 'Source Kick'); ?&gt;</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!


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.