Welcome Guest, Not a member yet? Register   Sign In
Redirect to what was just POSTed
#1

[eluser]Bionicjoe[/eluser]
I want to send users to a page that shows what they just posted in a form.

My SQL table generates an 'id' field using auto-increment, so it is not something the user posts.

The form is on /app/create page.
They should go to /app/view/'id#' page.

The create & view pages work just fine, but have to send the users back to the index page because I can't figure out how to create a redirect link like /app/view/'id#'. The table has just created the new id#.
#2

[eluser]Hyra[/eluser]
Not completely sure I understand the question, but couldn't you just have the model return the insert_id?

inside the create() function of app.php you might have something like:
Code:
$this->your_post_model->add($data);

the post model could do
Code:
function add($data) {
    // Your database stuff
    return $this->db->insert_id();
}

Then you can use this ID to redirect the user

Code:
$id = $this->your_post_model->add($data);
    header("location: /app/view/".$id);




Theme © iAndrew 2016 - Forum software by © MyBB