in reply to Re^6: Parse form data to database
in thread Parse form data to database

Regarding this code you just posted:

-- When you open a file for append access ( ">>file.name"), you don't need to seek to the end of the file -- you are already there. (Likewise, after you remove the "\r", you don't need to remove "\cM" -- that's a synonym for "\r".)

-- Why do you have those  <br> tags after the print statements to the output file? Are those really in your script, or is that just an artifact of learning how to post code here at PerlMonks? If those tags are really in the code, each one is a syntax error. Get rid of them.

-- Apropos of syntax errors, I hope that you have perl available on a local machine, so you can at least try  perl -cw your_script on the command line. This will tell you whether the code compiles, which you need to know before putting it on a server where you can't see the error logs.

-- Is it the case that nothing ever gets written to the output file at all? Do you get the "Error" message from your "dienice" call showing up as the result? What does that say? (Permission denied? something else? This is the second time I'm asking this question...)

As for giving you some sense of direction, I was hoping my earlier reply already did that. Writing the code for you would be wrong, but assuming that this particular script you posted is specifically for adding a new user to the database, I think a pseudo-code overview should be something like this:

# pring http header # decode params # if required params are not present # print explanation with link to sign-up page # exit # open database file for r/w access # get lock on that file # read current contents # if userid from form exists in database # close file # print explanation with link to sign-up page # exit # print new entry fields to database file # close file # print confirmation message
You need to make sure you add tests for error conditions with suitable calls to dienice as needed. As for the other components of the overall setup (login, password reminder), I'm hoping you can work those out in adequate detail on your own now. Good luck.

Replies are listed 'Best First'.
Re^8: Parse form data to database
by tryharder (Initiate) on May 13, 2006 at 17:03 UTC
    I sense from you some slight irritation with me and my quest, and I admit I also felt was somewhat frustrated with your attitude toward my quest, though sometimes what is said in print can be misinterpretted whereas saying it verbally is much more clear. Does that make sense?
    Anyway, I actually DO appreciate the fact you were unwilling to write the code for me. I DID NOT want or expect this of anyone. How else would I learn? So, thank you! However, examples and pointers which you did provide were acceptable. It was through an examination of my script that I hoped someone would point out where I was failing in coding. You finally did that and karma will shine on you greatly for it.
    I removed the "br" tags (living in an HTML coding world caused me to incorporate that by mistake), and deleted the "\r". The script NOW does as I intended. THANK YOU for that. btw: not that it is worth it now, here is the exact verbiage of the error you pointedly noted was requested twice:

    ERROR
    This error is very likely due to a mistake in your program.
    --------------------------------------------------------------------------------
    Follow the steps below to troubleshoot your error.

    The "steps below" is a comment to contact our Prof (which we can't do since it is a major project he won't assist on at any level) and a link to our Science department, which provides substantially less information than is available in Ovid's CGI Course. I plan to go over that course in depth. So, as you can see, and which I should have explained (though you might not have listened until you saw for yourself) the "error" response is worthless. Sorry I was not more expressive sooner. I have trouble putting all the detail into print sometimes.
    Botton line, I really am grateful for your assistance. All the best to you.