Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- print "content-type: text/html \n\n";
- use CGI':standard';
- use DBI;
- use DBD::mysql;
- for $key (param()){
- $input{$key} = param($key);
- }
- $score = 0;
- if($input{'answer1'} eq "1a"){
- $score++;
- }
- if($input{'answer2'} eq "2a"){
- $score++;
- }
- if($input{'answer3'} eq "3a"){
- $score++;
- }
- if($input{'answer4'} eq "4b"){
- $score++;
- }
- if($input{'answer5'} eq "5c"){
- $score++;
- }
- if($input{'answer6'} eq "6b"){
- $score++;
- }
- if($input{'answer7'} eq "7a"){
- $score++;
- }
- if($input{'answer8'} eq "8b"){
- $score++;
- }
- if($input{'answer9'} eq "9d"){
- $score++;
- }
- if($iput{'control'} eq "p6.p6"){
- $score++;
- }
- $score = $score * 10;
- $fname = $input{'First_Name'};
- $lname = $input{'Last_Name'};
- print "$fname"."<br>";
- print "$lname<br>";
- print "$score<br>";
- $platform = "mysql";
- $port = "3306";
- $host = "localhost";
- $database = "cmps401";
- $username = "cmps401";
- $password = "passdb";
- $dsn = "dbi:$platform:$database:$host:$port";
- $conn = DBI->connect($dsn, $username, $password);
- $dbh = DBI->connect('DBI:mysql:cmps401', 'cmps401', 'passdb') || die "Could not connect to database: $DBI::errstr";
- $query = "SELECT ID FROM chrisG WHERE FirstName='".lc($input{"First_Name"})."' AND LastName='".lc($input{"Last_Name"})."'";
- $result = $conn->prepare($query,$conn);
- $rv = $result->excute;
- if($rv > 0)
- {
- $id = mysql_result($result, "ID");
- $query = "UPDATE chrisG SET Score=".$score.", Time=Now() WHERE ID=".$id."";
- }
- else
- {
- $query = "INSERT INTO chrisG (FirstName, LastName, Score, Time) VALUES('".lc($input{"First_Name"})."', '".lc($input{"Last_Name"})."',$
- }
- $conn->disconnect();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement