Form/Controller within a Form/Controller - sequence of events


If this doesn’t make much sense, please forgive me - I’ve been working on a script for the last 15 hours straight (with 1/2 hour break for lasagne!) and I’ve hit a brick wall.

I’m in the middle of developing a fairly complex CMS for a client. Basically, depending on the information they fill in on form #1, the controller file #1 should either prompt them to fill in form #2 (which is dependant on some variables being passed from the data being posted in form #1) or proceed with the remaining processes and exit.

I’ve got the prompt working fine, based on a basic principal of if ($foo == ‘Yes’) {include ‘form2.html.php’;}, and the dependant data is being passed between the two forms perfectly, but my problem comes when that form #2 has been filled in, and controller file #2 has executed the various file uploads it needs to do as a result, I just can’t work out how to get it to return to the correct point in the controller file#1 to complete the rest of the processes… (which may well end up involving a form #3 with controller file #3!)

A straight exit(); command at the end of controller file #2 just gives me a blank screen, and header(‘Location: .’); takes me back a couple of steps too far.

The answer is probably staring me straight in the face, but my eyes and brain are a bit worn out.

Any ideas?


This kind of thing usually boils down to a misunderstanding between what you think PHP should assess a variable as vs what it actually does – and var_dump()ing vars prior and after the big code forks.

Is this all happening in one file?

Are you able to show us just the lines which constitute the code forks.

As I said, tired brain last night. Some sleep, a pair of fresh eyes and a bit of lateral thinking over breakfast and I’ve come up with a solution which doesn’t involve as much complexity with my controller files, and also encompasses a “view draft” prior to publishing. It’s all good. Thanks anyway!