Advertisement
Guest User

Untitled

a guest
Jun 23rd, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 2.39 KB | None | 0 0
  1. #!/usr/bin/perl
  2.  
  3. print "content-type: text/html \n\n";
  4. use CGI':standard';
  5. use DBI;
  6. use DBD::mysql;
  7.  
  8. for $key (param()){
  9.         $input{$key} = param($key);
  10. }
  11.         $score = 0;
  12.  
  13.          if($input{'answer1'} eq  "1a"){
  14.                 $score++;
  15.          }
  16.          if($input{'answer2'} eq "2a"){
  17.                 $score++;
  18.          }
  19.          if($input{'answer3'} eq "3a"){
  20.                 $score++;
  21.          }
  22.          if($input{'answer4'} eq "4b"){
  23.                 $score++;
  24.          }
  25.          if($input{'answer5'} eq "5c"){
  26.                 $score++;
  27.          }
  28.          if($input{'answer6'} eq "6b"){
  29.                 $score++;
  30.          }
  31.          if($input{'answer7'} eq "7a"){
  32.                 $score++;
  33.          }
  34.          if($input{'answer8'} eq "8b"){
  35.                 $score++;
  36.          }
  37.          if($input{'answer9'} eq "9d"){
  38.                 $score++;
  39.           }
  40.          if($iput{'control'} eq "p6.p6"){
  41.                 $score++;
  42.          }
  43.          $score = $score * 10;
  44.                 $fname = $input{'First_Name'};
  45.                 $lname = $input{'Last_Name'};
  46.                 print "$fname"."<br>";
  47.                 print "$lname<br>";
  48.                 print "$score<br>";
  49.  
  50.                 $platform = "mysql";
  51.                 $port = "3306";
  52.                 $host = "localhost";
  53.                 $database = "cmps401";
  54.                 $username = "cmps401";
  55.                 $password = "passdb";
  56.                 $dsn = "dbi:$platform:$database:$host:$port";
  57.                 $conn = DBI->connect($dsn, $username, $password);
  58.                 $dbh = DBI->connect('DBI:mysql:cmps401', 'cmps401', 'passdb') || die "Could not connect to database: $DBI::errstr";
  59.           $query = "SELECT ID FROM chrisG WHERE FirstName='".lc($input{"First_Name"})."' AND LastName='".lc($input{"Last_Name"})."'";
  60.  
  61.                 $result = $conn->prepare($query,$conn);
  62.                 $rv = $result->excute;
  63.  
  64.  
  65.                  if($rv > 0)
  66.                 {
  67.                         $id = mysql_result($result, "ID");
  68.                         $query = "UPDATE chrisG SET Score=".$score.", Time=Now() WHERE ID=".$id."";
  69.                 }
  70.                 else
  71.                 {
  72.                         $query = "INSERT INTO chrisG (FirstName, LastName, Score, Time) VALUES('".lc($input{"First_Name"})."', '".lc($input{"Last_Name"})."',$
  73.                }
  74.  
  75.                $conn->disconnect();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement