TIP: Click on subject to list as thread! ANSI
echo: pascal
to: ALL
from: RICKEY PARRISH
date: 1998-05-14 16:22:00
subject: CGI

Hello All!
        For school, I have to write a CGI program that the teacher can use to 
mark multiple choice tests for him.  I figure the easiest way to do this, is 
to make a .HTML file with the questions and use radio buttons to let the user 
choose the answer.  I found a working example CGI program, but it was written 
in PERL and I dont know PERL very well, and would prefer to write it in 
Pascal.  My only problem is this: I dont know how to read in the results from 
the submitted form.  Here is a snippet of the .HTML file:
--cut from SAMPLE.HTML--

**that is the perl cgi program i am running right now, but id rather use a 
pascal program that i can write from scratch
Who are the four original members of Metallica?
Lars Ulrich, James
Hetfield, Jason Newstead, Kirk Hammett
Lars Ulrich, Dave
Mustaine, Jason Newstead, Kirk Hammett
Lars Mustaine, Dave
Hetfield, Cliff Ulrich, James Burton
Lars Ulrich, Dave
Mustaine, Cliff Burton, James Hetfield
**in the perl program, it somehow reads the VALUE of the selected radio 
button from STDIN.  I've heard or STDIN before, but am not sure how to read 
from it.  Or if thats even the proper way to do it with pascal.  And there 
will be about 20 questions if that matters.  I only posted 1 to keep it 
ort.


--
        To make a long message longer, heres part of the SAMPLE.CGI
--cut from SAMPLE.CGI--
sub GET_FORM_DATA  {
#** When the user clicks on the Submit button labled
#** "Calculate Score" this CGI program is called, and the form
#** data is passed in STDIN.
read(STDIN, $save_string, $ENV{CONTENT_LENGTH});
@prompts = split(/&/,$save_string);
  foreach (@prompts)
    {
     ($tmp1, $tmp2) = split(/=/,$_);
      $tmp2 =~ s/\x2b/\x20/g;
      $tmp2 =~ s/%2C/\x2c/g;
      $tmp2 =~ s/%28/\x28/g;
      $tmp2 =~ s/%29/\x29/g;
      $fields{$tmp1}=$tmp2;
  }
$question1 = $fields{'question1'};
}
--
        So, if the user had selected the correct answer, which was radio 
button 4, the value of 4 would be passed to this cgi program, and it would be 
stored in the variable $question1, which i could then compare to what the 
actual answer should be and either add a mark to the persons score, or just 
leave it.
        Thanks for all the help.  TTYL
--- Maximus/2 2.02
---------------
* Origin: T-Shirts 'N Genes BBS Duncan Canada (250) 748-3408 (1:340/204)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.