Here is the php-source. Notice that we define two functions. One function that draws a scale of radiobuttons, another one that ships values of variables.
<HTML>
<BODY>
<?php
// the following file collects all the data
// make sure that your httpd may write to this file
$outfilename="test.out";
// the function scale implements a scale of radio-buttons
function scale ($varname,$comment) {
echo "<TABLE><TR><TD WIDTH=250>$comment</TD><TD>";
echo " (is not the case) ";
for ($i=1;$i<7;++$i) {
echo $i;
echo "<INPUT TYPE=RADIO VALUE=$i NAME=$varname> ";
}
echo "(is the case)</TD></TR></TABLE>";
}
function ship ($varname) {
global $outfile;
global $$varname;
fwrite ($outfile,$varname);
fwrite ($outfile,"=\"");
fwrite ($outfile,${$varname});
fwrite ($outfile,"\", ");
}
echo "<FORM METHOD=POST ACTION=$SCRIPT_NAME>";
// we first check whether the form was invoked for the first time:
if ($Ready == "") {
echo "Please fill in your age here: <INPUT TYPE=TEXT NAME=AGE><BR>";
scale ("RATEA","How do you rate A?");
scale ("RATEB","How do you rate B?");
echo "<P><INPUT TYPE=SUBMIT NAME=Ready VALUE=\"This is a useless button\">";
} else {
$outfile = fopen($outfilename,"a");
ship ("AGE");
ship ("RATEA");
ship ("RATEB");
fwrite ($outfile,"\n");
fclose($outfile);
echo "Thank you very much!";
}
?>
</FORM>
</BODY>
</HTML>