#!/usr/bin/perl # ########################################################################### # # The cgi that does the actual database modification via DBI # Security is handled by cookies and cookie.lib # Filename: dbmodify.cgi # -Neil Doane ########################################################################### push(@INC,"/var/lib/httpd/cgi-bin"); use DBI; require "cgi-lib.pl"; require "cookie.lib"; &ReadParse(*input); $action = $input{'action_type'}; $title = $input{'title'}; $catno = $input{'catalogno'}; $runtm = $input{'runtime'}; $langu = $input{'language'}; $annot = $input{'annotation'}; $id = $input{'id'}; $titleu = $title; $catnou = $catno; $runtmu = $runtm; $languu = $langu; $annotu = $annot; $title =~ s/'/\\'/g; $catno =~ s/'/\\'/g; $runtm =~ s/'/\\'/g; $langu =~ s/'/\\'/g; $annot =~ s/'/\\'/g; &GetCookies; $username = $Cookies{'userted'}; $password = $Cookies{'passwordted'}; $prepare = $Cookies{'prepared'}; $dbh = DBI->connect("DBI:mysql:filmlib",$username,$password) or die &ErrSpoiledCookie; print "Content-type:text/html\n"; if ( $action eq "modify") { $cursor = $dbh->prepare(" UPDATE Result3 SET Title='$title' , CatalogNo='$catno' , Runtime='$runtm' , Annotation='$annot' , Language='$langu' WHERE ID='$id' "); $cursor->execute; $cursor->finish; $dbh->disconnect; print "\n"; print <Modification Successful!
The Database Has Been Modified



This database entry has been modifed to the specification you requested.
This is what you submitted:
Title: $title
Catalog Number: $catno
Runtime: $runtm
Language: $langu
Annotation: $annot

[ Return to Main Page ]
MODIFIED } elsif ( $action eq "delete") { print "\n"; print <Modification Successful!
DELETION IN PROGRESS!!!!



Warning!!! You are about to delete the following record! If you choose to continue, this data will permanently be removed from the database. Proceed with caution.
This is the record you will be deleting:
Title: $title
Catalog Number: $catno
Runtime: $runtm
Language: $langu
Annotation: $annot

[ Return to Main Page ]

 

TRUFFLE } elsif ( $action eq "real_delete") { # Okay...they asked for it...delete the record $cursor = $dbh->prepare(" DELETE FROM Result3 WHERE ID='$id' "); $cursor->execute; $cursor->finish; $dbh->disconnect; print "\n"; print <Record Deleted
Record Deleted


The record you specified was deleted from the database permanently. This information cannot be recovered except by means of its re-addition to the database through the web interface or the restoration of the entire database from a backup system.

Have a nice day.:)

[ Return to Main Page ]

EATATJOES } elsif ( $action eq "add") { $cursor = $dbh->prepare(" INSERT INTO Result3 VALUES ('', '$title', '$catno', '$runtm', '$annot', '$langu')"); $cursor->execute; $cursor->finish; $dbh->disconnect; print "\n"; print <Modification Successful!
The Database Has Been Modified



This database entry has been modifed to the specification you requested.
This is what you submitted:
Title: $title
Catalog Number: $catno
Runtime: $runtm
Language: $langu
Annotation: $annot

[ Return to Main Page ]
TRMODIFIED } else { &ErrNoAction; exit 1; } # -----------Subroutines-------------# sub ErrSpoiledCookie { print "Content-type:text/html\n\n"; print <Film/Video Library - Security Error 2:ErrSpoiledCookie
Security Error

There has been a security-related error. The information passed from your browser as an identification Cookie was not valid. Possible reasons for this could be that a Cookie was not set properly or has expired since last login. Please keep the following in mind:
  1. Our Cookies expire at the end of every session. This means that
  2. Our Cookies expire at the end of every session. This means that if you disconnect from your browser and reconnect at a later time, the Cookie information held by your browser will no longer be valid.
  3. Starting from the initial interface of this database will help insure that a fresh Cookie is set in your browser.

Please go back and try again.

END_ERRSPOILEDCOOKIE &HtmlBot; } sub ErrNoAction { print "Content-type:text/html\n\n"; print <Film/Video Library - Script Error 1:ErrSpoiledCookie
Script Error

There has been a script-related error. Information the script expected (an action for this script to take) was missing from the data you provided. The most likely reason for this is that the script was called without an 'action_type' variable. Please keep the following in mind:
  1. This script has three possible actions, add records, modify records, and delete records.
  2. The variable 'action_type' contains the information needed to determine what action this script is to take.

Please go back and try again.

END_ERRNOACTION &HtmlBot; } sub HtmlBot { print "\n"; }