This is a discussion on Discussion on program structure within the alt.comp.lang.php forums, part of the PHP Programming Forums category; Hi! Once again I am building a simple app that shows data that users can add and manipulate from a ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi!
Once again I am building a simple app that shows data that users can add and manipulate from a form on a web page. I would like to discuss about simple simple solutions to these common problems. Please join in, and add your own comments, and questions. My question is, whats a clever way of handling the part where user adds data? I have simple solution like this: 'commands' are sent through GET (in url) to the server, where index.php or similar file includes other files accordingly. Now this doesn't work well with OO where I am headed. And I need lots of files, basically one or more per 'command' or 'action'. Say for instance I have 'add entry' action in a blog. First the app must show the user a form from which user can post their entry, then the app must handle that data (another php file, ie. clean data up and add it to the db) and finally display thanks on the client (third file, xhtml). Whew! |
|
|||
|
"Jam Pa" <anonanon@non-anon.org> wrote in message
news:Xns96627C2149454anonanonnonanonorgjp@213.243. 153.2... > Hi! > > Once again I am building a simple app that shows data that users can add > and manipulate from a form on a web page. > > I would like to discuss about simple simple solutions to these common > problems. Please join in, and add your own comments, and questions. > > My question is, whats a clever way of handling the part where user adds > data? > > I have simple solution like this: 'commands' are sent through GET (in url) > to the server, where index.php or similar file includes other files > accordingly. Now this doesn't work well with OO where I am headed. > > And I need lots of files, basically one or more per 'command' or 'action'. > Say for instance I have 'add entry' action in a blog. First the app must > show the user a form from which user can post their entry, then the app > must handle that data (another php file, ie. clean data up and add it to > the db) and finally display thanks on the client (third file, xhtml). > Whew! I put lots and lots of stuff in a single page. For instance I may have three different forms and form handlers in a single file. I keep them separate with something like if($_REQUEST['list']) { // something } else if($_REQUEST['save']) { // something else } else if($_REQUEST['delete']) { // something else } Keeps the number of pages small, and since they are all related to same area, all require the same settings, sessions and libraries, I just modify the action segments in the middle and I only need to write once the section where I include all libs and settings and shit. -- Welcome to Usenet! Please leave tolerance, understanding and intelligence at the door. They aren't welcome here. eternal piste erection miuku gmail piste com |
|
|||
|
Jam Pa wrote:
> Hi! > > Once again I am building a simple app that shows data that users can add > and manipulate from a form on a web page. > > I would like to discuss about simple simple solutions to these common > problems. Please join in, and add your own comments, and questions. > > My question is, whats a clever way of handling the part where user adds > data? > > I have simple solution like this: 'commands' are sent through GET (in url) > to the server, where index.php or similar file includes other files > accordingly. Now this doesn't work well with OO where I am headed. > Why not? What you've described is a front-controller pattern. If you're a patterns kind of person, you use the FC to multiplex the M[V]C objects. C. |