I'm building a multi-page "interview wizard" application. There are conditional branches, loops, and step skipping built in to the logic. Most of that logic is mapped in a MySQL table. Also in the table is a text field which contains context-sensitive (html formatted) 'Help' screens which get loaded into a variable each time the user reaches the next step.
The Help Screen concept got me to thinking ... what about putting each step's FORM code in another text field?
Please let me know your thoughts about keeping the html for a form in a text field versus keeping the html for the form in a file on the server. Pro's & con's Please!
Thanks!
Best place for forms
Moderator: General Moderators
-
jeffrydell
- Forum Commoner
- Posts: 77
- Joined: Thu Jan 17, 2008 4:39 pm
- Location: Menasha, WI
Re: Best place for forms
I have done this for a managers request. His thinking was then you can easily do a search on all the data on the site.
It may help when doing a generic template.
I would think the biggest downside is you have to query the database on every request there. I don't know numbers but I think a database query is slower then a file access, especially if it's a static file.
It may help when doing a generic template.
I would think the biggest downside is you have to query the database on every request there. I don't know numbers but I think a database query is slower then a file access, especially if it's a static file.
-
jeffrydell
- Forum Commoner
- Posts: 77
- Joined: Thu Jan 17, 2008 4:39 pm
- Location: Menasha, WI
Re: Best place for forms
Good thoughts - thanks! I'm already querying the db for that record as a part of taking the next step in the application, so maybe I'm saving time because I'm not doing that query AND loading the file after the query (which would contain the name of the file location in one of the fields).
Instead I'm just spankin' the code right in to a var ... and accessing memory is ALWAYS faster than disc access.
Instead I'm just spankin' the code right in to a var ... and accessing memory is ALWAYS faster than disc access.
- Christopher
- Site Administrator
- Posts: 13596
- Joined: Wed Aug 25, 2004 7:54 pm
- Location: New York, NY, US
Re: Best place for forms
I don't think it really matters and is just an implementation detail. Typically they are included from files because it is easy, but if you are already fetching the record then including the HTML in the record makes sense. This is what many CMSs do.
I would recommend making the thing datasource independent. Put the fetching code inside a Model object an then you can switch from files to database without modifying the app.
I would recommend making the thing datasource independent. Put the fetching code inside a Model object an then you can switch from files to database without modifying the app.
(#10850)
-
alex.barylski
- DevNet Evangelist
- Posts: 6267
- Joined: Tue Dec 21, 2004 5:00 pm
- Location: Winnipeg
Re: Best place for forms
I'd personally keep HTML form code in a file, just because it's easier to edit in a IDE as opposed to using the TEXTAREA in phpMyAdmin or other. You could build in a WYSIWYG which updated your FORM code I suppose, but most make a total mess of FORM's.
While I do store HTML content in databases, I keep everything else as native files for maximum portability and reuse.
While I do store HTML content in databases, I keep everything else as native files for maximum portability and reuse.