Advertisement
Guest User

Untitled

a guest
May 2nd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.41 KB | None | 0 0
  1. #!/usr/bin/perl
  2. use warnings;use strict;
  3. my ($buffer,$key,$value,$form,$pair,$missing,$name,$course,$gpa,$sport,$errors,$count);
  4. my ($user,$pass,$db,$host,$connectInfo,$dbh,$sth);
  5. my @pairs;
  6. my (%form,%name,%course,%gpa,%sport,%errors);
  7.  
  8. print "Content-Type:text/html\n\n";
  9.  
  10. $buffer = $ENV{'QUERY_STRING'};
  11.       @pairs = split(/&/, $buffer);
  12.       foreach $pair (@pairs){
  13.            ($key, $value) = split(/=/, $pair);
  14.            $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
  15.            $form{$key} = $value;
  16. }
  17.  
  18. sub checkFields
  19. {
  20.         foreach my $key (keys %form)
  21.         {
  22. #       $count = 0;
  23.         if ($form{$key} eq ""){
  24.         $errors{$key} = "Please Enter Somethin for $key";
  25. #       ++$count;
  26.                 }
  27.         }
  28. #       if ($count == 0){
  29. #       connectDB();
  30. #       }
  31. }
  32.  
  33. #sub connectDB
  34. #{
  35. #       $user = "tom";
  36. #       $pass = "boyg";
  37. #       $host = "db-zenit.mysql";
  38. #       $db   = "int420_101a07;
  39. #}
  40. print qq~
  41.   <html><head><title>Student Survey</title>
  42.   <style type="text/css">
  43.   * {margin:0;padding:0}
  44.   #container{width:960px}
  45.   #myform{width:850px;margin-left:20px}
  46.   ul{list-style-type:none}
  47.   li{margin:10px}
  48.   label{display:inline-block;width:190px;text-align:right;margin-right:10px}
  49.   input{width:250px}
  50.   .submit{margin-left:190px;float:left}
  51.   </style>
  52.   </head>
  53.   <body>
  54. ~;
  55.  
  56. sub displayForm
  57. {
  58.         print qq~
  59.         <div id="container">
  60.         <div id="myform">
  61.         <form action="aboutme.pl" method="GET">
  62.         <fieldset>
  63.         <legend>Student Survey</legend>
  64.         <ul>
  65.         <li><label>Full Name:</label><input type="text" name="name" value="$errors{'name'}" onclick="this.value='';" /></li>
  66.         <li><label>Favourite Sport:</label><input type="text" name="sport" value="$errors{'sport'}" onclick="this.value='';"  /></li>
  67.         <li><label>Favourite Seneca Course:</label><input type="text" name="course" value="$errors{'course'}" onclick="this.value='';" /></li>
  68.         <li><label>Current GPA:</label><input type="text" name="gpa" value="$errors{'gpa'}" onclick="this.value='';" /></li>
  69.         </ul>
  70.         <ul>
  71.         <li><button class="submit" type="submit">Send</button></li>
  72.         <li><button type="reset">Reset</button></li>
  73.         </ul>
  74.         ~;
  75. }
  76. sub closeHtml
  77.         {print "</fieldset></form></div></div></body></html>"}
  78.  
  79. checkFields();
  80. i       $count = 0;
  81. displayForm();
  82. closeHtml();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement