Jump to content

Front Controller and $_POST


punk_runner

Recommended Posts

Okay, so I have managed to build a front controller using Apache's mod_rewrite to parse clean looking URL's and route them to the appropriate action-controller and method.

 

But say that the user submitted an HTML form, like a registration form. The HTML form tag will redirect to something like www.domain.com/register/trial/90 which the front controller will route to:

 

new $controller->$method($args);

 

 

But how do I pass the form values stored in the $_POST global array to the controller/method?

 

Do I just roll them up in a new array called formValues and pass them between the parens, or is there a better way?

 

Stick them in a session? That seems sloppy....

 

 

 

Link to comment
Share on other sites

Yes, the front controller has access to both the $_POST and $_REQUEST arrays just like any script that accepted a URL, but what is the prefered way to then pass that info off to the action controller, because it has to be rolled up and passed through to whatever method controls registration, right?

Link to comment
Share on other sites

I never mentioned the $_POST or $_REQUEST arrays. Assuming your attempting to build around the MVC pattern, generally, this pattern gives access to (and creates) both a Request & Response object. These objects are generally available to the controller. Well, the Request object generally is, while the Response object might actually be available through the View.

 

Having said that, it's not always necessary, it's really just a design decision.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.