in reply to Re^4: Parse form data to database
in thread Parse form data to database
I tried to incorporate open(OUTF, "form.txt"); followed by a print OUTF for all the $FORM fields then close (OUTF); but it did not work.
It would be better if you showed us the code as it was when you tried that. Better still if you could also say exactly what you mean by "did not work". Did you include error checking on the "open" call? Do you have access to the web server's error log, so you can look up error messages that might show up there? Maybe you were trying to open a file for write access where the web server process does not have permission to do that.
Anyway, from how you described your situation and task, it sounds like this is a "web design" course that focuses on design in the technical, server-client transaction sense, rather than design in the artistic, UI-look-and-feel sense; and in that regard, it sounds like you might still be having trouble with some of the concepts. Here is what you said (reformatted slightly):
- Complete a form which, when submitted, calls a script that parses the data input into the form,
- checks a flat file to see if the User ID is present and
- if so, advise to select different User ID.
- If not found then confirm data entered.
- If former user does not remember password,
- provide form requesting the user ID, and
- on submit have password emailed to the individual, based on the email address from the flat file.
If that's all you have for a technical design spec, your problem is that you are missing a lot of essential detail for the overall transaction between client and server.
If the idea is to have a web service that allows creation of new user accounts (userid, password, name, email, postal address) as well as access to existing accounts (userid and password authentication required), then the initial page would typically have two different submit buttons: one for each action (create vs. login).
You could have those two different submit actions invoke different scripts, or you could have one script that handles both actions, and simply looks at the parameters to know which one to do for a given request.
The create action needs all the name and address info, needs to return to the preceding form if required fields are missing or if the given userid string is already taken, and otherwise (if everything is okay) needs to add the new entry to the database and return a confirmation page to the client.
The login action only needs the userid and password params, needs to validate these against the database, and if that fails, return a login form that allows the user to request an email reminder (submission of this separate form by the client only triggers an email if the given email address exists in the database); if the login succeeds, return a confirmation page (and presumably provide access to something else as well).
Do you think you can do that by Monday? I could suggest (I expect others here will) that you consider using the CGI module, but the man page for that is quite long, and you might not have time to absorb it adequately (though you might just want to spend 10 minutes skimming over it -- maybe it will help).
For "passing the course", your current handling of the cgi params etc would probably suffice -- unless the prof is a stickler for secure design. One thing that you really should think about: just because you have a form that feeds parameters to your cgi script, this does not mean that your script will only get requests from that form. You should not trust that the parameter string will always be what you would expect from the form; e.g. only accept parameters whose names match what you need from the form.
If after passing the course (or not, as the case may be) you are still interested in the technical challenge, you can move into using a real database for the user info (or at least making sure your flat-file database is "hardened" to avoid problems of concurrent access from different clients).
(minor updates to fix grammar and add clarity)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Parse form data to database
by tryharder (Initiate) on May 13, 2006 at 05:19 UTC | |
by graff (Chancellor) on May 13, 2006 at 05:58 UTC | |
by tryharder (Initiate) on May 13, 2006 at 17:03 UTC |