[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 215
  • Last Modified:

Problems with CGI script

Here is the CGI script I am working on.  I have run it through the PERL Syntax checker and it gives me errors on the 'print <<"...";' statements, the 'exit;' statement, and the closing '}'.  I was wondering if you could tell me why?  Thanks!

#!/usr/bin/perl

require "subparseform.lib";
&Parse_Form;

$uid = $formdata{'uid'};
$pwd = $formdata{'pwd'};

use Win32::ODBC;

$db = new Win32::ODBC("DSN=CPCustomDB;UID=$uid;PWD=$pwd") || &Failed_Login;

######################
#start error routine for login
######################
Sub Failed_Login {

print "Content-type: text/html\n\n";
print <<"Failed Login";

<HTML>
<HEAD>
<TITLE>Failed Login</TITLE>
</HEAD>
<BODY BGCOLOR=#FFFFFF>
<TABLE BORDER=0 WIDTH=600 CELLSPACING=0 CELLPADDING=0>
      <TR>
            <TD ALIGN=CENTER VALIGN=TOP WIDTH=125 BGCOLOR=#4682B4> </TD>
            <TD ALIGN=CENTER VALIGN=TOP WIDTH=25 BGCOLOR=#FFFFFF> </TD>
            <TD ALIGN=LEFT VALIGN=TOP WIDTH=450 BGCOLOR=#FFFFFF> </TD>
      </TR>
</TABLE>
<TABLE BORDER=0 WIDTH=600 CELLSPACING=0 CELLPADDING=0>
      <TR>
            <TD ALIGN=CENTER VALIGN=TOP WIDTH=125 BGCOLOR=#4682B4> </TD>
            <TD ALIGN=CENTER VALIGN=TOP WIDTH=25 BGCOLOR=#FFFFFF> </TD>
            <TD ALIGN=LEFT VALIGN=TOP WIDTH=450 BGCOLOR=#FFFFFF>
                  <FONT FACE="Times" SIZE=+4 COLOR=TAN><CENTER><B>The Computer Place</B></CENTER></FONT>
                  <FONT SIZE=+1><CENTER>Intranet Database</CENTER></FONT><BR>
                  <P> 
                  <P><FONT FACE="Helvetica" COLOR="Red" SIZE="6"><CENTER><STRONG>ERROR!</STRONG></CENTER></FONT>
                  <P><FONT SIZE=3><STRONG>The server encoutered an error when trying to log you into the database using the username and password that you supplied.  Please check your username and password and try again.  Otherwise, please contact the database administrator.</STRONG></FONT>
                  <P><CENTER><FORM ACTION="http://domain.name/index.html"><INPUT TYPE="Submit" NAME="Go Back" VALUE="<<  Go Back"></FORM></CENTER>
            </TD>
      </TR>
</TABLE>
<TABLE BORDER=0 WIDTH=600 CELLSPACING=0 CELLPADDING=0>
      <TR>
            <TD ALIGN=CENTER VALIGN=TOP WIDTH=125 BGCOLOR=#4682B4> </TD>
            <TD ALIGN=CENTER VALIGN=TOP WIDTH=25 BGCOLOR=#FFFFFF> </TD>
            <TD ALIGN=LEFT VALIGN=BOTTOM WIDTH=450 BGCOLOR=#FFFFFF><FONT COLOR="tan"><STRONG> </STRONG></FONT></TD>
      </TR>
</TABLE>
</BODY>
</HTML>

Failed Login
exit;
}
######################
#end error routine for login
######################

##################
#start normal display
##################
print "Content-type: text/html\n\n";

print<<"Form Layout";

<HTML>
<HEAD>
<TITLE>Table Selection</TITLE>
</HEAD>
<BODY BGCOLOR=#FFFFFF>
<TABLE BORDER=0 WIDTH=600 CELLSPACING=0 CELLPADDING=0>
      <TR>
            <TD ALIGN=CENTER VALIGN=TOP WIDTH=125 BGCOLOR=#4682B4> </TD>
            <TD ALIGN=CENTER VALIGN=TOP WIDTH=25 BGCOLOR=FFFFFF> </TD>
            <TD ALIGN=LEFT VALIGN=TOP WIDTH=450 BGCOLOR=FFFFFF> </TD>
      </TR>
</TABLE>
<TABLE BORDER=0 WIDTH=600 CELLSPACING=0 CELLPADDING=0>
      <TR>
            <TD ALIGN=CENTER VALIGN=TOP WIDTH=125 BGCOLOR=#4682B4> </TD>
            <TD ALIGN=CENTER VALIGN=TOP WIDTH=25 BGCOLOR=FFFFFF> </TD>
            <TD ALIGN=LEFT VALIGN=TOP WIDTH=450 BGCOLOR=FFFFFF>
                  <FONT FACE="Times" SIZE=+4 COLOR=TAN><CENTER><B>The Computer Place</B></CENTER></FONT>
                  <FONT SIZE=+1><CENTER>Intranet Database</CENTER></FONT><BR>
                  <P> 
                  <P>Please select the table you wish to view from the list below.
                  <P><FORM ACTION=http://domain.name/cgi-bin/tableselection.cgi METHOD=POST ID=tableredirect>

Form Layout

                        print "<INPUT TYPE=\"Hidden\" NAME=\"uid\" VALUE=$uid>";
                        print "<INPUT TYPE=\"Hidden\" NAME=\"pwd\" VALUE=$pwd>";

print<<"Form Layout";

                        <INPUT TYPE=\"Radio\" NAME=\"table\" ID=\"customers\">Customer Table<BR>
                        <INPUT TYPE=\"Radio\" NAME=\"table\" ID=\"inventory\">Inventory List<BR>
                        <P><CENTER><INPUT TYPE=\"Submit\" NAME=\"Submit\" VALUE=\"Continue\"></CENTER>
            </TD>
      </TR>
</TABLE>
<TABLE BORDER=0 WIDTH=600 CELLSPACING=0 CELLPADDING=0>
      <TR>
            <TD ALIGN=CENTER VALIGN=TOP WIDTH=125 BGCOLOR=#4682B4> </TD>
            <TD ALIGN=CENTER VALIGN=TOP WIDTH=25 BGCOLOR=FFFFFF> </TD>
            <TD ALIGN=LEFT VALIGN=BOTTOM WIDTH=450 BGCOLOR=FFFFFF><FONT COLOR=\"tan\"><STRONG><P> <P> <P> <P> </STRONG></FONT></TD>
      </TR>
</TABLE>
</BODY>
</HTML>

Form Layout
#################
#end normal display
#################
0
Gimpster
Asked:
Gimpster
  • 2
1 Solution
 
GimpsterAuthor Commented:
Edited text of question.
0
 
GimpsterAuthor Commented:
Adjusted points to 110
0
 
ozoCommented:
What was the error message?  Was it
syntax error at - line 20, near "print"
Can't find string terminator "Failed Login" anywhere before EOF at - line 20 (#1)
   
    (F) Perl strings can stretch over multiple lines.  This message means that
    the closing delimiter was omitted.  Because bracketed quotes count nesting
    levels, the following is missing its final parenthesis:
   
        print q(The character '(' starts a side comment.);
   
    If you're getting this error from a here-document, you may have
    included unseen whitespace before or after your closing tag. A good
    programmer's editor will have a way to help you find these characters.
   
Uncaught exception from user code:
        Can't find string terminator "Failed Login" anywhere before EOF at - line 20.

Or was it because you misspelled sub as Sub?
0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now