#!/usr/bin/perl $imgprefix='../'; if ($ENV{'REQUEST_METHOD'} eq 'POST') { read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'}); } else { $buffer=$ENV{'QUERY_STRING'}; } @pairs=split(/&/,$buffer); foreach $pair (@pairs) { ($name,$value)=split(/=/,$pair); $value =~ tr/+/ /; $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack('C',hex($1))/eg; $in{$name}=$value; if ($name ne 'q1' && $name ne 'q2' && $name ne 'error') {$hidden .= "\n";} } open(infile,'treatment-advisor-template.html'); while() { $page.=$_; } close(infile); $content .= <<"print_tag";

Let the Treatment Advisor help provide you with information which will help you to decide which is the right treatment for you.

Simply answer these questions so that your needs can be assessed and receive information on appropriate treatments*. There are five questions in total.

*When taking a constipation remedy, always read the label. If constipation persists or is particularly troublesome, please consult your doctor. print_tag if ($in{'error'} == 1) {$content .= '

Please select an answer for all the questions

';} $content .= <<"print_tag";
$hidden

Q1) Are you (or your child) male or female?

print_tag %options=(0,'Male',1,'Female'); foreach $key (sort{$a<=>$b} keys %options) { $content .= "


Q2) What age are you (or your child)?

print_tag %options=(0,'under 6',1,'6-12',2,'13-35',3,'36-54',4,'over 54'); foreach $key (sort{$a<=>$b} keys %options) { $content .= "

Click here for question 3
print_tag $page =~ s/\[content\]/$content/; print<<"print_tag"; Content-Type: text/html $page print_tag