<?php include '../util.inc'; include 'surcom.inc'; // Figure out the URL of the processing script. $proc = preg_replace('@/[^/]+$@', "/surread.php", $_SERVER["SCRIPT_NAME"]); // First line of file is name of survey. Read it, then start generating // HTML for the survey form. $surid = substr($_SERVER['PATH_INFO'], 1); $surdef = open_sur($surid); $title = fgets($surdef, 40); start($title); echo <<<END We would appreciate if you would be willing to fill out our survey. It will only take a few minutes of your time.<p> <b>Many Thanks!</b><p> <form action="$proc" method="post"> <input type="hidden" name="surv_path_info" value="$surid"> <table> END; // One line per question, separated by ':'. Generate each question // as a line in a table. $qno = 1; // Question numbers. while(! feof($surdef)) { // Get the line and split it into parts. $line = fgets($surdef, 1024); $parts = explode(':', $line); // Generate the question. $ques = htmlspecialchars(array_shift($parts)); echo "<tr align=\"left\" valign=\"top\"><td>$ques</td>"; // Generate the response alternatives. $rno = 1; echo "<td align=\"left\" valign=\"top\">"; foreach($parts as $resp) { $resp = htmlspecialchars($resp); $resp = preg_replace('/ /', ' ', $resp); if($rno > 1) echo " \n"; echo "<nobr><input type=\"radio\" name=\"ques_$qno\" ", "value=\"$rno\">$resp</nobr>"; ++$rno; } echo "</td></tr>\n"; ++$qno; } fclose($surdef); // Close the HTML stuff, and generate submit and clear buttons. echo <<<END </table> <br><input type="submit" name="submit" value="Submit Survey"> <input type="reset" value="Clear Survey"> </body> </html> END ?>