Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #This is going to be the user login check and will set a cookie
- use DBI;
- use CGI qw(:standard);
- use strict;
- #Connection error
- sub showErrorMsgAndExit {
- print header(), start_html(-title=>shift);
- print (shift);
- print end_html();
- exit;
- }
- #Connecting to the database
- my $dbUsername = "root";
- my $dbPassword = "password";
- my $dsn = "DBI:mysql:f18final:localhost";
- my $dbh = DBI->connect($dsn, $dbUsername, $dbPassword, {PrintError => 0});
- #error checking
- if(!$dbh) {
- print header(), start_html(-title=>"Error connecting to DB");
- print ("Unable to connec to the database");
- print end_html();
- exit;
- }
- print header;
- print start_html(-title=>'Edit Classes');
- #Need to execute sql command and then iterate row by row
- my $sql = "SELECT classID, classname, department, classnum, grade, credits FROM tblclasses";
- my $sth = $dbh->prepare($sql);
- $sth->execute();
- print "<table border=solid 1px>"; #start of table
- print "<tr><th>Class Name</th><th>Department</th><th>Class Number</th><th>Grade</th><th>Credits</th><td>Edit class</td>";
- print "</tr>";
- while( my @row = $sth->fetchrow_array) {
- print "<tr><td>";
- print $row[1];
- print "</td>";
- print "<td>";
- print $row[2];
- print "</td>";
- print "<td>";
- print $row[3];
- print "</td>";
- print "<td>";
- print $row[4];
- print "</td>";
- print "<td>";
- print $row[5];
- print "</td>";
- print "<td>";
- print "<form action=http://localhost/cgi-bin/editing.pl method = 'post' >";
- my $classid = $row[0];
- my $classname = $row[1];
- my $dep = $row[2];
- my $classnum = $row[3];
- my $grade = $row[4];
- my $credit = $row[5];
- print "<input type='hidden' name='classid' value='$classid' />" ;
- print "<input type='hidden' name='classname' value='$classname' />" ;
- print "<input type='hidden' name='dep' value='$dep' />" ;
- print "<input type='hidden' name='classnum' value='$classnum' />" ;
- print "<input type='hidden' name='grade' value='$grade' />" ;
- print "<input type='hidden' name='credit' value='$credit' />" ;
- prin#!/usr/bin/perl
- #This is going to be the user login check and will set a cookie
- use DBI;
- use CGI qw(:standard);
- use strict;
- #Connection error
- sub showErrorMsgAndExit {
- print header(), start_html(-title=>shift);
- print (shift);
- print end_html();
- exit;
- }
- #Connecting to the database
- my $dbUsername = "root";
- my $dbPassword = "password";
- my $dsn = "DBI:mysql:f18final:localhost";
- my $dbh = DBI->connect($dsn, $dbUsername, $dbPassword, {PrintError => 0});
- #error checking
- if(!$dbh) {
- print header(), start_html(-title=>"Error connecting to DB");
- print ("Unable to connec to the database");
- print end_html();
- exit;
- }
- print header;
- print start_html(-title=>'Edit Classes');
- #Need to execute sql command and then iterate row by row
- my $sql = "SELECT classID, classname, department, classnum, grade, credits FROM tblclasses";
- my $sth = $dbh->prepare($sql);
- $sth->execute();
- print "<table border=solid 1px>"; #start of table
- print "<tr><th>Class Name</th><th>Department</th><th>Class Number</th><th>Grade</th><th>Credits</th><td>Edit class</td>";
- print "</tr>";
- while( my @row = $sth->fetchrow_array) {
- print "<tr><td>";
- print $row[1];
- print "</td>";
- print "<td>";
- print $row[2];
- print "</td>";
- print "<td>";
- print $row[3];
- print "</td>";
- print "<td>";
- print $row[4];
- print "</td>";
- print "<td>";
- print $row[5];
- print "</td>";
- print "<td>";
- print "<form action=http://localhost/cgi-bin/editing.pl method = 'post' >";
- my $classid = $row[0];
- my $classname = $row[1];
- my $dep = $row[2];
- my $classnum = $row[3];
- my $grade = $row[4];
- my $credit = $row[5];
- print "<input type='hidden' name='classid' value='$classid' />" ;
- print "<input type='hidden' name='classname' value='$classname' />" ;
- print "<input type='hidden' name='dep' value='$dep' />" ;
- print "<input type='hidden' name='classnum' value='$classnum' />" ;
- print "<input type='hidden' name='grade' value='$grade' />" ;
- print "<input type='hidden' name='credit' value='$credit' />" ;
- print "<input type = 'submit' name = 'submit' value = 'Edit'>";
- print "</form>";
- print "</td>";
- print "</tr>";
- }
- print "</table>";
- #Need to make a table and populate it with text boxes of all the class data
- print "</table>"; #End of table
- print end_html();
- t "<input type = 'submit' name = 'submit' value = 'Edit'>";
- print "</form>";
- print "</td>";
- print "</tr>";
- }
- print "</table>";
- #Need to make a table and populate it with text boxes of all the class data
- print "</table>"; #End of table
- print end_html();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement