Hello everyone! I have a question regarding the following script. I am having problems getting the first elsif to redirect to another .cgi script. I have found out it is due to the printing of content type of text and html at the top of the script, but I need it to print out the table near that beginning of the script. Any help would be appreciated.
#!/usr/bin/perl print "Content-type: text/html\n\n"; use CGI qw(:standard -debug); use strict; use DBI; #declare variables my ($key, @sysletter, $systems, $dbh, $dsn); my $row = param('row'); my $action = param('action'); my $value = param('value'); #assign initialization string username and password to variables my $dsn = "DBI:mysql:IST221"; my $user_name = "ist221student"; my $password = "password"; my $dbh = DBI->connect($dsn, $user_name, $password); #preparing and executing the statement. if ($action eq "v") { my $sth = $dbh ->prepare("SELECT * FROM products order by pname"); $sth->execute(); print "<HTML><FONT SIZE=15>\n"; print "<BODY><CENTER>\n"; print qq(<table width="70%" border="0" cellspacing="5" align="center"> +<tr><th>Product<th>U/I<th>Quantiy<th>Cost</tr>); while (my @row = $sth -> fetchrow_array()) { print qq(<tr><td>$row[1]<td align=center>$row[2] <td align=center>$row +[3]); printf "<td align=right>%.2f</tr><p>",$row[4]; } } elsif ($action eq "a") { print "Location: http://carrotcake.nsm.tridenttech.edu/tablefunction.c +gi\n\n"; } elsif ($action eq "u") { print "this is the update page under construction\n"; } elsif ($action eq "d") { print "this is the delete page under construction\n"; } else { print "Error!\n"; } print qq (</table>); print "<HTML><FONT SIZE=3>\n"; print "<A HREF='http://carrotcake.nsm.tridenttech.edu/dbhome.html'>\n" +; print "Return to Selection Page"; print "</HTML></FONT>\n";

In reply to Redirection question by student

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.