in reply to Parse form data to database

Well tryharder, there are a million ways to do this. And I think also wise to point out, there are a million levels on which you can do this- that is.. how far you can take it. how deep this works.. How secure, etc.

What you describe can be done in a few hours, or a few weeks. It depends on how far you want it to 'work'. This *is* for educational purposes - right? So.. I'm not sure- if this is for educational purposes, should you do this/be shown how.. minimally? so it works.. or what some others here would call 'looks like it works but is really broken'- ..

Or maybe.. since this is for a class- it should be a real world example- complete with taint checking... maybe email checking.. etc etc.

tryharder, you will have to honeslty ask yourself- do you just want to pass this class- or are you learning to code. Because, if you are learning to code for real,I think this should take you many many many days to do. A ton of stuff to learn.

If you are just passing your class- And there is absolutely nothing wrong with that! It can take you a lot less time. I don't know the rigurousness and strictness of your instructor.

Regardless; - I would suggest:

Those are some basic things. Also, why don't you post a url to your stuff? maybe a place where your code can be seen.. Basically.. this whole thing is pretty involved and complex. You don't usually get people coming here and saying "tell me how would i make a website?" -- hahah.. but that is a little bit what you are asking here.. it's too vague. People, tend to do more of.. asking on specific things when they run into problems. So... Take your project appart piece by piece first and ask questions on perlmonks as problems arise.. you will be astonished with the ammount of good energy and help you will receive here.- Be more specific.

Replies are listed 'Best First'.
Re^2: Parse form data to database
by tryharder (Initiate) on May 12, 2006 at 17:59 UTC
    Thank you for the great response. Yes, I am trying to pass the class, and eventually might delve deeper into coding. This Web design course was a prerequisite for my program. I do find it interesting and challenging, but had no real intent to get so deep into scripting. I'll check the link provided for clues on what I can do further.

      Ahh.. yeah.. oh dear. Yeah man, coding's not for everyone. It's a choice.. And this whole thing..
      it's not exaclty a "and next week we start studying for the finals and -- oh dear.. we almost forgot to do unix.. yes.. perl. .ok.. let's do a little project.. yes yes .. let's see.. let's have a web site where users can make accounts, change passwords, save data to a database via a form and maybe retrieve lsot passwords, let's have 20 or more people who don't exactly really want to do this try it out.. and open the stuff to the whole internet do our servers can get hacked and then uhm... ok you got a week. Oh! Almost forgot! It's almost ASP hour!"

        Leocharre, here's my dilema. I've worked a week on this thing, and moved inches only to be set back several feet. I have the form working, with form action posting to cgi script, which then returns a confirmation page. But, I don't think the script is correct for what else I need to do. I am sure the process is simple, if one knows basic code. I'm not concerned with security just getting it to perform as follows: 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. Here is the cgi script I have which is in the form action used on the form submit. It only sends confirmation and input submitted:
        #!/usr/bin/perl print "Content-type:text/html\n\n"; read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'}); @pairs = split(/&/, $buffer); foreach $pair (@pairs) { ($name, $value) = split(/=/, $pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg; $value =~ s/\n/ /g; # replace newlines with spaces $value =~ s/\r//g; # remove hard returns $value =~ s/\cM//g; # delete ^M's $FORM{$name} = $value; } print <<EndHTML; <html><head><title>Thank you</title></head> <body> <h2>Thank You, $FORM{'fnameRN'} $FORM{'lnameRN'}!</h2> Here is the information you provided:<p> <table width="38%" border="1" cellspacing="0" cellpadding="0"> <tr> <td>First Name: </td> <td>$FORM{'fnameRN'}</td></tr> <tr> <td>Last Name: </td> <td>$FORM{'lnameRN'}</td></tr> <tr> <td>Street Address1: </td> <td>$FORM{'addr1RN'}</td></tr> <tr> <td>Street Address2: </td> <td>$FORM{'addr2RN'}</td></tr> <tr> <td>City: </td> <td>$FORM{'cityRN'}</td></tr> <tr> <td>State: </td> <td>$FORM{'stRN'}</td></tr> <tr> <td>Zip: </td> <td>$FORM{'zipRN'}</td></tr> <tr> <td>Email: </td> <td>$FORM{'emailRN'}</td></tr> <tr> <td>UserID: </td> <td>$FORM{'uidRN'}</td></tr> <tr> <td>Password: </td> <td>$FORM{'pwd1RN'}</td></tr> </table> Thank you for your feedback.<p> <a href="http://matrix.csis.pace.edu/~s06-it154a-s04/register.html">Cl +ick here</a> to return to form to make any changes, OR<br> <a href="http://matrix.csis.pace.edu/~s06-it154a-s04/cgi_scripts.html" +>Click here</a> to return to the home page. </body></html> EndHTML sub dienice { my($msg) = @_; print "<h2>Error</h2>\n"; print $msg; exit; }
        Preceding the print <EndHTML; 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. I have until midnight Monday to get this resolved, or will just have to submit as is. If you or anyone can assist, I would be grateful.