Welcome Guest, Not a member yet? Register   Sign In
moving through a form based app
#1

[eluser]Unknown[/eluser]
i have a basic question that i am sure has been answered before (although i can't find anything)

i have a step-by-step form based app that takes values and passes them to the next form and the next...

right now i have a controller with a function and view for each form. i need to post the form to the function and call the next form. the problem is matching the url with the form function. i can post the data and load the next view, but the url is showing the wrong function. example:

function addCar() {
//do post variable stuff...
$this->load->view('addAccessories');
}

if i have a form addCar, i can post it to func addCar() and get the data. then i can load the next form addAccessories, but it still has "addCar" in the url.

so how can i have a function and view of the same name, then pass the flow to then next func and view.

thanks!
#2

[eluser]Michael Wales[/eluser]
I'm doing something very similar - 25 questions, one question per page. I am using a session to store the user's answer to each question (one variable, comma-delimited) - if your users are registered members, you could just use a database instead.

A quick run-down:
1. User visits /poll to read instructions, clicks next (link to /poll/1).
2. On /poll/1 they answer the question - this form's method is itself (/poll/1).
3. Upon submission /poll/1 is reloaded - the field is validated, if good - add the session stuff and redirect to /poll/2. If it's not good - they just get to try again.

The links /poll/2 are actually a remapped Controller - going to a questions method and using the # as the ID for the questions to pull from the database.




Theme © iAndrew 2016 - Forum software by © MyBB