I am in a Net-Centric computing course. We have a lab assignment to ask a user to enter data into a form and the Perl code should echo the data back. The HTML is not set up to validate data, so hitting submit without entering data will not trigger a validation message. My code causes the Perl code to be shown in the browser I tried running the html on 3 browsers. The data didn't echo with any of the 3 browsers.instead of echoing the form data. I entered my HTML and Perl programs below: The instructor gave me feedback and said to keep the "T" flag in the first line of my Perl code. Why does it show code instead of the form data?
Thank you.
<!doctype html>
<head>
<meta charset="utf-8">
<title>index.html</title>
<style type = "text/css">
body {background-color: lightblue;}
div.background
{
background-image: url(images/10 pins.jpg);
background-position: 100% center;
background-origin: border-box;
background-repeat: repeat;
}
.dropbtn {
background-color: #4CAF50;
color: white;
padding: 16px;
font-size: 16px;
border: none;
cursor: pointer;
}
/* The container <div> - needed to position the dropdown content */
.dropdown {
position: relative;
display: inline-block;
}
/* Dropdown Content (Hidden by Default) */
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
/* Links inside the dropdown */
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
/* Change color of dropdown links on hover */
.dropdown-content a:hover {background-color: #f1f1f1}
/* Show the dropdown menu on hover */
.dropdown:hover .dropdown-content {
display: block;
}
/* Change the background color of the dropdown button when the dropdow
+n content is shown */
.dropdown:hover .dropbtn {
background-color: #3e8e41;
}
</style>
<meta name = "keywords" content = "bowling, club, central Illinois
+">
<link href="styles/style.css" rel="stylesheet" type="text/css">
<!--The following script tag downloads a font from the Adobe Edge Web
+Fonts server for use within the web page. We recommend that you do no
+t modify it.--><script>var __adobewebfontsappname__="dreamweaver"</sc
+ript><script src="http://use.edgefonts.net/adamina:n4:default.js" typ
+e="text/javascript"></script>
</head>
<body>
<div class ="background">
<header id="header"><h1>Central Illinois Bowling Club</h1></header
+>
<p><a href = "standings.html">Last Year's Standings</a></p><br
+>
<div style="background-color:lightgreen"><img src="images/
+bowling lane.png" width="293" height="187" alt="Bowling Lane"/>
<img src="images/team.png" width="273" height="181" alt="T
+eam"/>
<img src="images/scoresheet.jpg" width="273" height="181"
+alt="Scoresheet"/></div><br>
<p> Welcome to the Central Illinois bowling Club site. We meet the thi
+rd Saturday of the month from September through March. We decide on a
+ restaurant for dinner, the meet at a bowling alley. There are four b
+owling centers we use and use the centers on a rotating basis. We wel
+come persons of all ages who want to:
<ul id="objectives"><li>A group who wants to build relationships</
+li>
<li>A fellowship of those who like bowling or want to learn a
+bout the sport</li>
<li>Engage in a healthy hobby</li>
</ul>
Provide your name and phone number if you are interested. The coordina
+tor (me) will contact you soon.<br><br>
<FORM ACTION="cgi-bin/sample_register.cgi" METHOD="POST">
First name: <input type="text" name="fname">
Last name: <input type="text" name="lname"><br>
<input type="radio" id="male" name="gender" value="male">
<label for="male">Male</label>
<input type="radio" id="female" name="gender" value="female">
<label for="female">Female</label><br>
<label for="age">Age (between 15 and 70):</label>
<input type="number" id="age" name="age" min="15" max="70"><br>
<label for="Skill">Select skill level:</label>
<select id = "Skill">
<option value="Beginner">Beginner</option>
<option value="Occasional">Occasional Bowler</option>
<option value="Regular">Regular Bowler</option>
<option value="HighAvg">High Average Bowler</option>
</select><br>
<p> Select other sports you participate in:<br>
<input type="checkbox" name="sport" value="Baseball"> Baseball<br>
<input type="checkbox" name="sport" value="Tennis"> Tennis<br>
<input type="checkbox" name="sport" value="Golf"> Golf<br>
<input type="checkbox" name="sport" value="Running"> Running<br>
<input type="checkbox" name="sport" value="Football"> Football<br>
+</p>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</form>
</div>
</body></html>
#!/usr/bin/perl -wT
use strict;
use CGI;
my $obj = new CGI;
my $datastring ="";
# read information from form
my $fname = $obj->param( "fname" );
my $lname = $obj->param( "lname" );
my $gender = $obj->param( "gender" );
my $age = $obj->param( "age" );
my $Skill = $obj->param( "Skill" );
my $sport2 = "";
foreach my $sport (@sport) {
$sport2 .= "$sport ";
}
# Save the data into a text file
$datastring = "Saved Data\n\nFirst name: $fname\nLast name: $lname\nGe
+nder: $gender\nAge: $age\nSkill: $Skill\nSports: $sport2\n\n";
open(OUTDATA, ">>", "data.txt") or die "Error in opening file data.txt
+";
print OUTDATA $datastring;
close(OUTDATA);
#Send the info back
print $obj->header( "text/html" ),
$obj->start_html(
-title => "Form Data",
-topmargin =>"0"
),
$obj->h1("User information"),
$obj->p("User name: $fname"),
$obj->p("Last name: $lname");
$obj->p("Gender: $gender"),
$obj->p("Age: $age"),
$obj->p("Skil: $skill"),
$obj->p("Sports: $sport2"),
$obj->end_html;