jasmine has asked for the wisdom of the Perl Monks concerning the following question:
ps i know this code could be neater, but at this stage i just want it to work, so please don't pick it to pieces just try and help solve the problem.#!C:\Perl\bin\Perl.exe "%1" %* print "Content-type: text/html\n\n"; use DBI; require ('C:\WINNT\Profiles\Administrator\Desktop\screens\cgi-lib.pl') +; &ReadParse; if ($in{locateContact} eq "NULL") { print "<body bgcolor=\"#FFFFCC\">"; print"<b><font color=\"#FF0000\" face=\"Arial\"><b>NO CONTACTS ARE AVA +ILABLE</font></b><br><br>"; print "<input type=\"BUTTON\" value=\"OK\" onClick=\"location.href = ' +main.cgi'\" name=\"OKContact\">"; } else { my $dbh = DBI->connect("DBI:Sybase:CRAP", "sa", ""); #connects to data +base $sth = $dbh->prepare(qq{ select CONTACT_FNAME, CONTACT_LNAME, CONTACT_TITLE, CONTACT_DESKPH#, CONTACT_MOBILE#, CONTACT_PAGER#, CONTACT_PAGER_SP, CONTACT_FAX#, CONTACT_EMAIL from NSS.dbo.CONTACT WHERE CONTACT_# = $in{locateContact} }) or die "Can't prepare SQL statement: $DBI::errstr\n"; $sth->execute or die "Can't execute: $DBI::errstr\n"; my ( $modContactFName, $modContactLName, $modContactTitle, $modContact +DeskPH, $modContactMobile, $modContactPager, $modContactPagerSP, $mod +ContactFax, $modContactEmail); $sth->bind_columns (undef, \$modContactFName, \$modContactLName, \$mod +ContactTitle, \$modContactDeskPH, \$modContactMobile, \$modContactPag +er, \$modContactPagerSP, \$modContactFax, \$modContactEmail); while ( @row = $sth->fetchrow() ) {} @array=split /\-+/,$modContactDeskPH; @array2=split /\-+/,$modContactPagerSP; @array3=split /\-+/,$modContactFax; print <<"EOF"; <html><head><title>Modify/Delete Contact</title></head> <body bgcolor="#FFFFCC"> <div align="center"></div> <form method="post" action="deleteContact.cgi"> <input type="hidden" name="delContactNumber" value="$in{locateContac +t}"> <input type="hidden" name="delSiteNumber" value="$modSiteNumber"> <table width="88%" border="1" bgcolor="#CCCCCC" align="center" hei +ght="46"> <tr> <td height="28"> <div align="center"><font face="Arial" size="6" color="#CC0033"> +Contact Details</font></div> </td> </tr> <tr> <td height="45"> <div align="center"> <input type="submit" name="Submit" value="Delete Contact"> </div> </td> </tr> </table> </form> <form method="post" action="modifiedContact.cgi"> <div align="center"> <table width="88%" border="1" height="314" bgcolor="#CCCCCC"> <tr> <input type="hidden" name="modContactNumber" value="$in{locateCont +act}"> <input type="hidden" name="delSiteNumber" value="$modSiteNumber"> <td colspan="2" height="106"> <div align="center"><br> <table width="96%" border="0"> <tr> <td width="28%"> <div align="right"><font color="#CC0033" size="1">* </font +><font face="Arial">First Name:</font></div> </td> <td width="26%"> <input type="text" name="modContactFName" size="22" value= +"$modContactFName" disabled="true"> </td> <td width="25%"> <div align="right"><font color="#CC0033" size="1">* </font +><font face="Arial">Title:</font></div> </td> <td width="21%"> <input type="text" name="modContactTitle" size="22" maxlen +gth="40" value="$modContactTitle"> </td> </tr> <tr> <td width="28%"> <div align="right"><font color="#CC0033" size="1">* </font +><font face="Arial">Last Name:</font></div> </td> <td width="26%"> <input type="text" name="modContactLName" size="22" value= +"$modContactLName" disabled="true"> </td> </tr> </table><br> </div> </td> </tr> <tr> <td colspan="2" height="40"> <div align="center"><br> <table width="99%" border="0"> <tr> <td> <div align="right"><font face="Arial">Desk Phone Number:</fo +nt></div> </td> <td> <input type="text" name="modContactDeskPH1" size="3" value=" +$array[0]"> <input type="text" name="modContactDeskPH2" size="3" value=" +$array[1]"> <input type="text" name="modContactDeskPH3" size="13" value= +"$array[2]"> </td> <td> <div align="right"><font face="Arial">Fax Number:</font></di +v> </td> <td> <input type="text" name="modContactFax1" size="3" value="$ar +ray3[0]"> <input type="text" name="modContactFax2" size="3" value="$ar +ray3[1]"> <input type="text" name="modContactFax3" size="13" value="$a +rray3[2]"> </td> </tr> <tr> <td> <div align="right"><font face="Arial">Mobile Phone Number:</ +font></div> </td> <td> <input type="text" name="modContactMobile" size="24" maxleng +th="15" value="$modContactMobile"> </td> <td> <div align="right"><font face="Arial">Email Address:</font>< +/div> </td> <td> <input type="text" name="modContactEmail" size="24" maxlengt +h="40" value="$modContactEmail"> </td> </tr> <tr> <td> <div align="right"><font face="Arial">Pager Service:</font>< +/div> </td> <td> <input type="text" name="modContactPagerSPName" size="11" va +lue="$array2[0]"> <input type="text" name="modContactPagerSP" size="11" value= +"$array2[1]"> </td> <td> <div align="right"><font face="Arial">Pager Number:</font></ +div> </td> <td> <input type="text" name="modContactPager" size="24" maxlengt +h="8" value="$modContactPager"> </td> </tr> </table><br> </div> </td> </tr> <tr> <td> <i><font face="Arial">Sites:</font></i><br> <blockquote> EOF $sth2 = $dbh->prepare(qq{ select NSS.dbo.SITE.SITE_#, SITE_NAME FROM NSS.dbo.SITE, NSS.dbo.SITE_CONTACT, NSS.dbo.CONTACT WHERE NSS.dbo.SITE.SITE_# = NSS.dbo.SITE_CONTACT.SITE_# AND NSS.dbo.CONTACT.CONTACT_# = NSS.dbo.SITE_CONTACT.CONTA +CT_# AND NSS.dbo.CONTACT.CONTACT_# = $in{locateContact} }) or die "Can't prepare SQL statement: $DBI::errstr\n"; $sth2->execute or die "Can't execute: $DBI::errstr\n"; my ( $modSiteNumber, $modSiteName); $sth2->bind_columns (undef, \$modSiteNumber, \$modSiteName); while ( @row2 = $sth2->fetchrow() ) { print "<input type=\"checkbox\" name=\"sites\" value=\"$modSiteN +umber \" CHECKED><font face=\"Arial\">$modSiteName</font><br>"; } $sth3 = $dbh->prepare(qq{ select SITE_#, SITE_NAME FROM NSS.dbo.SITE WHERE SITE_# NOT IN (select NSS.dbo.SITE.SITE_# FROM NSS.dbo.SITE, NSS.dbo.SITE_CONTACT, NSS.dbo.CONTA +CT WHERE NSS.dbo.SITE.SITE_# = NSS.dbo.SITE_CONTACT.SITE_ +# AND NSS.dbo.CONTACT.CONTACT_# = NSS.dbo.SITE_CONTACT.C +ONTACT_# AND NSS.dbo.CONTACT.CONTACT_# = $in{locateContact}) }) or die "Can't prepare SQL statement: $DBI::errstr\n"; $sth3->execute or die "Can't execute: $DBI::errstr\n"; my ($newSiteNumber, $newSiteName); $sth3->bind_columns (undef, \$newSiteNumber, \$newSiteName); while ( @row3 = $sth3->fetchrow()) { print "<input type=\"checkbox\" name=\"newSites\" value=\"$newSi +teNumber,\"><font face=\"Arial\">$newSiteName</font><br>"; } print <<"EOD"; </blockquote> </td> </tr> <tr> <td colspan="2" height="37"> <div align="right"> <input type="submit" name="modContact" value="Update"> <input type="reset" name="Reset" value="Reset"> <input type="BUTTON" value="Home" onClick="location.href = 'ma +in.cgi'" name="homeContact"> </div> </td> </tr> </table> </div> </form> </body> </html> EOD }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Checkbox values
by snax (Hermit) on Dec 21, 2000 at 15:14 UTC | |
by davorg (Chancellor) on Dec 21, 2000 at 15:17 UTC |