#!/usr/bin/perl

#------------------------------------
# Author:        Heather Uthoff
# Creation Date: 10/13/2013
# Doc Version:   1.0
# Website URL:   http://webtrain.austincc.edu/~huthoff/cgi-bin/perlassign.cgi
# Additional Comments:
#--------------------------------------
$| = 1;
use CGI::Carp qw(fatalsToBrowser);
print "Content-type: text/html\n\n"; 


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;
  $DATA{$name} = $value;
}

$first = $DATA{'first'};
$last = $DATA{'last'};
$street = $DATA{'street'};
$extra = $DATA{'extra'};
if ($extra ne ""){
 $extra = $extra."</br>"; }
$city = $DATA{'city'};
$state = $DATA{'state'};
$zip = $DATA{'zip'};
$first = $DATA{'first'};
$hear = $DATA{'hear'};
$rating = $DATA{'rating'};
if ($rating eq "") {
 $rating = "Zero";}
$comments= $DATA{'comments'};
if (index($comments, "Type Here") != -1) {
 $comments = "";}
if ($DATA{'webdesign'} ne ""){
 $interest = $DATA{'webdesign'};}
if ($DATA{'webserver'} ne ""){
 if ($interest ne ""){
  $interest = $interest.", "; }
 $interest = $interest.$DATA{'webserver'};}
if ($DATA{'studywebdesign'} ne ""){
 if ($interest ne ""){
  $interest = $interest.", "; }
 $interest = $interest.$DATA{'studywebdesign'};}
if ($DATA{'jobwebdesign'} ne ""){
 if ($interest ne ""){
  $interest = $interest.", "; }
 $interest = $interest.$DATA{'jobwebdesign'};}
if ($DATA{'studywebserver'} ne ""){
 if ($interest ne ""){
  $interest = $interest.", "; }
 $interest = $interest.$DATA{'studywebserver'};}
if ($DATA{'jobwebserver'} ne ""){
 if ($interest ne ""){
  $interest = $interest.", "; }
 $interest = $interest.$DATA{'jobwebserver'};}
			

print qq~
<!DOCTYPE html>  
<!--------------------------------------
Author:        Heather Uthoff
Creation Date: 02/09/2014
Doc Version:   2.0
Website URL:
Additional Comments:
-------------------------------------->

<!--CTYPE html PUBLIC "-//W3C//DTD HTML 4.00 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dt"-->

<html>
<head>
<title>Perl Assignment Thank You</title>
<meta name="ROBOTS" content="noindex,nofollow">
<meta name="description" content="Perl Assignment Thank You">
<meta name="keywords" content="xhtml, web publishing, html, CSS, Perl, CGI">
</head>
<!--CTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
 "http://www.w3.org/TR/html4/loose.dt-->

<html>
<head>
<title>Cascading Style Sheets</title>
<meta name="ROBOTS" content="noindex,nofollow">
<meta name="description" content="Perl Assignment Thank You">
<meta name="keywords" content="xhtml, web publishing, html, CSS, Perl, CGI, Thank You">
<link href="../index.css" rel="stylesheet" type="text/css" media="screen">
</head>
 <div id="top">
  <h1>HEATHER UTHOFF</h1>
  <h4>
   <a href="../index.htm">ABOUT</a>&nbsp&nbsp&nbsp
   <a href="../courses/index.html">COURSES</a>&nbsp&nbsp&nbsp
   <a href="../portfolio/index.html">PORTFOLIO</a>&nbsp&nbsp&nbsp
   <a href="../courses/html/resume.html">RESUME</a>&nbsp&nbsp&nbsp
  </h4>
 </div>
 <div id="assignment">
  <h3> Assignment: Create a Survey with a Corresponding CGI script written in Perl</h3>
  <p class="two">
  <b>Thank You for Your Response!</b><br/><br/>
  <b>You submitted the following:</b><br/><br/>
  $first $last<br/>
  $street <br/> $extra
  $city $state $zip <br/><br/>
  <b>You heard about us through</b> $hear <br/>
  <b>Rating:</b> $rating out of Five Possible<br/><br/>
  <b>You are currently involved in </b>$interest <br/>
  <b>Additional Comments:</b> $comments<br/>
  </p>
</body>
</html>
~;

