#!/bin/sh
string=? ; PLTHOME=/usr/local/plt/ export PLTHOME ; exec /usr/local/bin/mzscheme -r $0 "$@"

(require (lib "cgi.ss" "net"))
(require (lib "date.ss"))

(define (html-enclose tag options body)
	(string-append "<" tag " " options ">" body "</" tag ">"))

(define (h1-center string)
	(html-enclose "h1" "align=\"center\"" string))

(define dummy-bindings '((name . "Joe Schmoe") (address . "jschmoe@adelphi.edu")))

(let*	(
	(current-date (date->string (seconds->date (current-seconds))))
	(bindings `((date . ,current-date) ,@(get-bindings)))
	; (bindings `((date . ,current-date) ,@dummy-bindings))
	 (name (extract-binding/single 'name bindings))
	 (label (string-append "Thanks, " name))
	)

	(with-output-to-file
"/users/staff/math/sbloch/html/class/172/unsafe/survey.results"
		(lambda ()
			(write bindings)
			(newline))
		'append)
	(generate-html-output label
		`(,(h1-center label) 
		  "Your data have been saved."
		  "<p>"
		  ; "Current directory: " ,(current-directory) "<p>"
		  ,@(bindings-as-html bindings))
	)
)
