Cameron Harr's CS462 Page
Home  About  CS 462  Contact 
Lab 2 -- CGI Script 100% Pure Vim Web Site
Home > Lab 2

 
Stuff:

Log:

    Since we set up the CGI directories and permissions in lab1, there were no server side modifications we had to make. We simply had to make the script we were writing executable (chmod 755 survey.cgi).

    As far as writing the script, it was my first time writing CGI and I initially started by using the use CGI directive. However, after spending a long time on that trying to make it work, I gave up and switched to a mode using a library called subparseform.lib which includes a nice function called formdata() which will grab the parameters sent via POST or GET.

    My basic algorithm is as follows:

    • First try to read in any cookies and store those as script-wide variables.
    • Then I have a number of if statements to test if there has been a request to delete the CSV file and if so, to let the user authenticate. If they do authenticate, the file is deleted.
    • I then check to see if buttons are defined in the input parameters from the survey or from a new user entering their name. Depending on the case, I will set a cookie and and call a subroutine prevuser() which will take them to the survey again.
    • If none of the if statements apply, then the user is directed to the newuser() function to enter their name and start the survey process.
    • I also have subroutines to write out the information from the survey to the CSV file, and one to delete that file.

For more great website ideas, visit Jaden.
Copyleft © 2002 Cameron No rights reserved.
Last Updated 01/14/02