|
| |
CGI Scripts
|
Web Hosting Services |
rate_op1.plThis script parses the information and appends the result to a file. It then reopens the file and calculates the overall percentages of the poll. It displays the results in a table format. #!/usr/bin/perlread(STDIN, $buffer,$ENV{'CONTENT_LENGTH'});$buffer =~ tr/+/ /;$buffer =~ s/\r/ /g;$buffer =~ s/\n/ /g;$buffer =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;$buffer =~ s/<!--(.|\n)*-->/ /g;$buffer =~ tr/\\|[|]|<|!|"|$|{|}|*|#|'|>|||;|%/ /; @pairs = split(/&/,$buffer);foreach $pair(@pairs){($key,$value)=split(/=/,$pair);$formdata{$key}.="$value";}$op1=$formdata{'op1'};open (INFO,">>op1.txt"); #For Appendingprint INFO "$op1\n";close (INFO);open (INFO,"op1.txt"); #for Reading@array=<INFO>;close (INFO);chomp (@array);$count=0;$num1=0;$num2=0;$num3=0;foreach $line (@array) {$count++;if($line =~ /val1/){$num1++;}if($line =~ /val2/){$num2++;}if($line =~ /val3/){$num3++;}}$percent1=($num1/$count)*100;$percent2=($num2/$count)*100;$percent3=($num3/$count)*100;$per1=sprintf("%4.2f",$percent1);$per2=sprintf("%4.2f",$percent2);$per3=sprintf("%4.2f",$percent3);print "Content-type:text/html\n\n"; #Follow with blank lineprint "<html>\n";print "<head><title>Results Opinion #1</title>\n";print "<style type=\"text/css\">\n";print "h2\{font-family: Arial;font-style : normal ;font-size : 12pt; font-weight :bold;text-align :center \}\n";print "p\{ font-family: Arial;font-style : normal ;font-size : 10pt; font-weight :normal;text-align :left\}\n";print "td\{ font-family: Arial;font-style : normal ;font-size : 10pt; font-weight :normal;text-align :right\}\n";print "</style>\n";print "</head>\n";print "<body>\n";print "<div align=\"center\">\n";print "<h2>Results Opinion #1 Pop Up Advertising</h2>\n";print "<table width=\"400\" cellpadding=\"5\" cellspacing=\"0\" border=\"1\">\n";print "<tr><th>Percent</th><th>Opinion</th></tr>\n";print "<tr align=\"center\" valign=\"top\">\n";print "<td align=\"right\" colspan=\"1\" rowspan=\"1\">$per1</td>\n";print "<td align=\"left\" colspan=\"1\" rowspan=\"1\"><p>I really like this type of advertising. Even if I have to close a pop up every couple of seconds it gives me the option of accepting or rejecting the advertisement.</td>\n";print "</tr>\n";print "<tr align=\"center\" valign=\"top\">\n";print "<td align=\"right\" colspan=\"1\" rowspan=\"1\">$per2</td>\n";print "<td align=\"left\" colspan=\"1\" rowspan=\"1\"><p>I don't even notice pop up advertisements. I just close them as they open and go on my way.</td>\n";print "</tr>\n";print "<tr align=\"center\" valign=\"top\">\n";print "<td align=\"right\" colspan=\"1\" rowspan=\"1\">$per3</td>\n";print "<td align=\"left\" colspan=\"1\" rowspan=\"1\"><p>I think this is the most aggravating form of advertisement on the internet.</td>\n";print "</tr>\n";print "</table>\n";print "<br>\n";
print "<a href=\"http://www.createafreewebsite.net\">Return to Main Page</a>\n";print "</div>\n";print "</body>\n";print "</html>\n"; |
Create a Website with CMS
|
| Net Success 2000 Plus Inc PO Box 1508 Somerset, KY 42502 Copyright 2000 - 2007 Net Success 2000 Plus Inc Last Modified: January 19, 2008 |