[ic] Real basic question(s) about tables & forms

argonaut molasses naugahyde@earthlink.net
Wed, 20 Sep 2000 19:14:16 -0400


Hi,
    Please excuse my ignorance and/or laziness, but I have some really
simple questions
about database tables & forms that several days of hacking the example
files & reading docs
has yet to clarify.
    I need to know what the basic requirements are for allowing random
users to insert
new records into a database table via an html form.   Told you this was
simplistic.
Unfortunately I've found it difficult to extrapolate the answer to this
from the mvdocs file
and/or the example catalogs, in the first case because details are given
for *updating* but
not for *inserting* into a database, and in the latter because all the
pages with forms for
user submission of new db records (new_account, account...)
simultaneously deal with both
the external userdb & internal minivend tables in a confusing way.
    So before I go on to explain a bit about what I've tried, let me ask
anybody that's read this far
& knows the answer to spell this out for me in kindergarten terms.
i.e.-
"you must set mv_data_enable to 1, use [process-target] for the form
action, etc".

    OK, so I have Interchange running a modified version of the barry
demo
(www.simplyhealing.net), w/ MySQL as the DBM, and I have created a new
table called 'medical' for
the test_barry database which is meant to hold information submitted via
a form
(www.simplyhealing.net/cgi-bin/barry/onlineform.html).  The records are
to be indexed
by the client's [data session id], which is placed into the primary key
for the new table, med_session.
That part appears to work fine.   I have included the directive [set
mv_data_enable]1[/set] to the SCRATCH space.
I use [process-target] for the form's action, and I define as <INPUT
type=hidden> the following variables -

mv_doit="set"
mv_nextpage="formsuccess"
mv_data_function="set"
mv_data_table="medical"
mv_data_key="med_session"
mv_data_fields="comma-separated list of the names of all the fields in
the table medical"

    I have files medical.txt & medical.sql in the
.../catalogs/barry/products directory, and the permissions
are the same as for all the other .txt/.sql pairs in that directory.  I
also have a medical.mysql file in the
../catalogs/barry/mysql directory which properly echos the structure of
the medical table.
The weird thing is I have on at least 3 occasions managed to
successfully insert a new record into the
table through this form, but it always fails after this to insert
another record (& yes, I am refreshing the
session_id so as to not attempt an insert w/ the same primary key).
These failed attempts show no sign of
failure to the user of course, but in the error.log I see entries like -

/cgi-bin/barry/process.html Attempted database update without
permission, table=medical key=AZEevAAF

    I cannot seem to isolate what conditions are changing between the
successful & failed submissions, but one possibility
that occurs to me is that, on the successful attempts, I may have logged
in as the administrator & then as
a test user account, and the mv_username variable is still set to
'interchange' (i.e.-admin).    Another is that the
successes only come after removing
../catalogs/barry/products/medical.sql & restarting minivend ... why
they would then
fail after an initial success, I don't know.

    Surely I am doing something painfully obvious & wrong, but damn if I
can see precisely what.

    I would love to be enlightened on this score, & will be eternally
grateful, etc. to anyone who can help me out w/ this.

    Thanks in advance,

    Josh