[eluser]Greg Aker[/eluser]
I am tackling my first "real" project with Code Igniter. As a nice way to learn, a family member is letting me re-design/code their companies website.
I am using FreakAuth_light for the admin backend, and to change/update the site when an admin is logged in, I am using a lot of ajax in place editing, etc (learning that too =). So far, most everything is working nicely. They don't really care how it's done, so long as they can change text & add photos...they don't want to have to learn any code, and so far, there will be no need for them to use any code.
But I have run into one problem so far.
I am setting up a "projects blog" where he will be able to post new projects he's done, along with photos, etc. I have my form built, but I'm having issues getting it to redirect back to the page with "pretty urls" when the form is submitted.
Truncated form:
Code:
<?=form_open('featuredProject/projectUpdate/'. $featured->project_id);?>
</form>
So I have added the "project_id" to the url of where it is to be updated. Probably not the best way to do it, but you can see why below.
Here is my form controller:
Code:
function projectUpdate()
{
$urlSegment = $this->uri->segment(3);
$this->db->where('project_id', $urlSegment);
$this->db->update('featuredproject', $_POST);
$urlTitle = $this->db->query("SELECT url_title FROM featuredproject WHERE project_id = $urlSegment");
redirect ("featuredProject/article/$urlTitle" );
}
When it goes back to the "featuredProject/article" page, it sets the "$urlTitle" to NULL.
I have tried putting this: redirect ("featuredProject/article/" . $urlTitle ); and redirect ('featuredProject/article/' . $urlTitle );
Here is the "article" controller.
Code:
function article()
{
$data['title'] = "Featured Project";
$title = $this->uri->segment(3);
$query = $this->db->getwhere('featuredproject', array('url_title' => $title));
$data['featured'] = $query->row();
//COMMENTED OUT FOR THE TIME BEING SO I KNOW I CAN SEE ERROR OUTPUT IF IT DOESN'T WORK.
//if ( $title == '0' ) {
//redirect('featuredProject/');
//}
$this->load->view('featuredProject/featuredProjectEntry_view', $data);
}
Any ideas?
Many Thanks in Advance,
-greg