One of your problems comes from the fact that you're printing the header at the top of your script, before your redirect logic.

#!c:\phpdev\perl\bin\perl.exe print "Content-type: text/html\n\n"; # -----8<-----

The print line in this block interferes with the redirect statements later in the code. Move your print line from this block to your HTML print block, like so:

# -----8<----- else { print "Content-type: text/html\n\n"; # Line moved here. print "<HTML>\n"; print "<HEAD><TITLE>Patton Industries</TITLE><BASEFONT SIZE=5></HEAD>\ +n"; # -----8<-----

In fact, you're printing these headers manually when you should be using CGI.pm. Doing so is simple enough, try this:

my $cgi = new CGI(); # Declare this near the top of the script. print $cgi->header(); # In place of your "Print: content-type..." +statement.

A similar convention exists for your redirect statements. Be sure to review the CGI.pm documentation. It will simplify things for you, even if it looks more complicated now.

A few other suggestions/concerns:

Hope this helps.

/Larry


In reply to Re: HTTP headers and redirection by larryp
in thread HTTP headers and redirection 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.