in reply to Re^5: Will this work?
in thread Will this work?

The original code was from a friend who modified Matt Wright's WWWboard code a little

Well, that's the problem right there. There have been numerous comments about "Matt's Scripts" here at the monastery, including statements like:

The last three quotes come from the same thread, which you might want to look at because it also provides a number of very useful resources (although it's now 6 years old).

Note that the NMS project mentioned above can be found here: http://nms-cgi.sf.net/ (UPDATE: actually, a better link would be: http://sourceforge.net/projects/nms-cgi/, which shows clear evidence of fairly recent maintenance by our esteemed davorg, among others.)

Bottom line: with regard to the code in the OP, the best course of action will be to ditch it and start over, using some better prototype as a starting point.

(UPDATE: I think it's worth pointing out that the name "NMS" derives from "Not Matt's Scripts".)