Serving PHP code from DB

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am writing a content management system that will serve pages from a MySQL database. Most of it is working very well.

The problem comes in dealing with HTML forms.

I have a set of form validation routines that I've used on prior projects, but I seem to be having problems when trying to serve these forms from the database.

The way my routines work on an individual page is that the user enters data into the form and Submits. The form action calls the same page (calls itself) and some PHP code checks each field to see if it meets the validation criteria. If it does then some more PHP code (on the same page) writes the data into the database. If it does NOT, then the form is re-displayed with a detailed error message and the erroneous fields are highlighted via CSS. This recurs - the page keeps calling itself until all the data validates. This works well on individual pages.

With the CMS, each article or item that will appear on a page is in the PAGECONTENT table. I have put the PHP code that runs my forms into the appropriate field, with another field indicating that this is PHP code rather than straight text.

The PROBLEM is that the PHP code does not work in the same way on my generated pages as it did when on separate pages. I tried 'eval'-ing the code from the database, but it generates only the initial form and does not do any of the validation. None of the variables seem to be getting passed along. I just tried saving the code as a separate file and 'include'-ing it, with the same result - I see the first pass of the form, but not the error-correction.

I seem to be missing something very basic here.

If it would help, the test page is

  http://goforthstudio.com/cfva/index.php?thispage=submit

the way it SHOULD work is at:

  http://goforthstudio.com/cfva/submitnews.php

If anyone can point me in the right direction I'd appreciate it. I can fall back to calling individual pages for the few forms that I need, but I'm hoping for a more elegant solution. Is there an existing class for forms that would do this better. I'd considered packaging my validation routines for distribution, but not like this!

Thank you for any assistance.

Nelson

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux