Question
PHP MySQL Insert form submission
I'm a teacher, and I'm giving Internet-based assignments to
my class. Ideally, I'd like for them to type their findings into a
webpage, press "submit," and have the page's contents go into a
database so I can review their answers before class. The page would
have a couple of paragraphs describing the first problem, then a
textarea where students can enter an answer, then a couple more
paragraphs describing the second problem, then another textarea for
the answer, and so on for about a half dozen problems.
I've set up a database table to capture the answers with three fields: studentID, questionID, and questionAnswer (there are two other tables for students and questions). My initial thought was to ask for the studentID at the top of the page, then have a separate form for each answer, with a "submit" button at the bottom of the page, together with buttons for them to print the page and email themselves a copy of it. But I've learned that it's possible to submit only one form at a time, so I'm not sure this will work. I've thought of perhaps creating a separate "submit" button for each form and making them invisible, then having a button at the bottom that somehow "presses" each submit button in turn. But I don't know how to implement that, nor do I know if that's the best way to do it.
So here are my questions:
(1) Am I on the right track, or is there conceptually a better way to make this work?
(2) How do I get the studentID from the top of the page into the database?
(3) How do I get the questionID (which identifies the question the student is answering) into the database?
This is my first foray into anything like this, and I'm trying to teach myself with David Powers' book PHP for Dreamweaver 8. So far I can view the database records and insert a single record into the database with the Insert Record Wizard. I know I have a ways to go, and I would be grateful for any help and also for any code or pseudo-code.
Thank you.
Joe Herl
I've set up a database table to capture the answers with three fields: studentID, questionID, and questionAnswer (there are two other tables for students and questions). My initial thought was to ask for the studentID at the top of the page, then have a separate form for each answer, with a "submit" button at the bottom of the page, together with buttons for them to print the page and email themselves a copy of it. But I've learned that it's possible to submit only one form at a time, so I'm not sure this will work. I've thought of perhaps creating a separate "submit" button for each form and making them invisible, then having a button at the bottom that somehow "presses" each submit button in turn. But I don't know how to implement that, nor do I know if that's the best way to do it.
So here are my questions:
(1) Am I on the right track, or is there conceptually a better way to make this work?
(2) How do I get the studentID from the top of the page into the database?
(3) How do I get the questionID (which identifies the question the student is answering) into the database?
This is my first foray into anything like this, and I'm trying to teach myself with David Powers' book PHP for Dreamweaver 8. So far I can view the database records and insert a single record into the database with the Insert Record Wizard. I know I have a ways to go, and I would be grateful for any help and also for any code or pseudo-code.
Thank you.
Joe Herl
