if ($op=='save') { validate if validated include('saveFile.php') op = 'view' else error message stuff op = 'reedit' }
if ($op=='reedit') { prep submitted data for reediting, include error message(s) } elseif ($id=='new') { prep 'blank' data, set defaults } elseif ($id>0) { retrieve data for display or editing }
if ($op=='edit' || $op=='reedit') { create form field for data entry } else { massage data for display } Merge data with HTML template file Display final page
That's basically my template. The "core" file is really just the logic, data retrieval is obviously done through a function call. The display piece, the html, is in a separate file and is structured for handling simple data display or data entry form fields. The logic dictates the role of the template, data entry or display. It's also then very simple to create a display for cellphones, just create a different html template. I've tried to follow the MVC (Model View Controller) design pattern concept, which has worked very well for me.
Hope that helps.
On Mar 8, 2005, at 6:11 AM, Vinayakam Murugan wrote:
Hi
I have always felt for reasons for cleanliness and clarity, it is better to have the validation and insert / update statements in a seperate file rather than have it in the same script.
Case 1 ---------- //file:form.php if $_POST then validate Insert or update on success else if $_GET['primarykey'] then show form for editing else show form for adding fi <form action="form.php" method=post> Show form </form>
Case 2 ---------- //file:form1.php if $_GET['primarykey'] then show form for editing else show form for adding fi <form action="formvalidate.php" method=post> Show form </form>
However in the second case, in case of an error, displaying the data becomes an issue.
Any recommended ways for server side validation
-- Warm Regards ~~~~~~~~~~~~ Vinayak
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
-- Brent Baisley Systems Architect Landover Associates, Inc. Search & Advisory Services for Advanced Technology Environments p: 212.759.6400/800.759.0577
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php