Another great resource that covers CGI/Web programming security basics is
Ovid's online CGI programming course, particularly lesson #3,
Basic Security with CGI.pm. It has great information about untainting your data, including that naughty NULL byte.
I learned tons from reading this quick and condensed course.
higle