i might be talking to myself here a bit... but never the less.
one of the things i want to do is allow for a regex for each field name as well as setting if the field can be updated by the user (as opposed to admin).
If i use the last option and have the two tables, one for user and one for settings with latter having structure
ID | User_Editable | Regex
After the user submits the form i do something lile:
$query = SELECT from settings WHERE User_Editable = 'Y'
start loop through
and set:
$fieldname == "$array['fieldname'];
$regex == "$array['regex'];
now i know that the fields submitted by the user from the form will have same name as fieldname (if not they are an error so we don't want to use them anyway)
so i do:
PHP Code:
// we have got all the fieldnames that are user_editable sent to us. we are now going to go through them each one by one and make sure that the fields do not fail the regex. If they do we build an error message, if they do not
we build the SQL statement to insert.
if (ereg ("$regex", $$fieldname)) {
$query .= ", $fieldname == '$$fieldname'"
} else {
$error .= "<b>$fieldname value missing or invalid</b>";
$continue = 0;
}
now just to work out how best to store the regex in the database...
Bookmarks