I am also trying to redirect a user to an HTML page if a certain condition is met. I am using cgi.pm and when I try the code you mentioned (included below) it gives me the error: Status: 302 Found Uri: Location: Content-type: text/html
my $q = new CGI; print $q->redirect("http://busybody.w1.com/html/2010assignment.html");
Any ideas on what I am doing wrong?
Thanks-
Laura
My entire script is as follows:
#!/usr/local/bin/perl -w # 2010b.pl use CGI; require ("cgi-lib.pl"); my $q = CGI->new(); print $q->header(); $studentid = $q->param('studentid'); $password = $q->param('password'); $CSC = $q->param('CSC'); $assignment = $q->param('assignment'); $file = $q->param('path'); if ($CSC eq "CSC2010") { $openfile = "CSC2010.txt"; open (IN, "<$openfile") or die "Can't open $openfile\n"; $foundusername = false; $foundpassword = false; while ($line = <IN>) { chomp($line); my ($realstudentid,$realpassword) = split /\|/, $line; if ($realstudentid eq $studentid){ $foundusername = true; if ($realpassword eq $password){ $foundpassword = true; print $q->redirect("http://busybody.w1.com/html/2010assignmen +t.html\n\n"); exit; } } } if ($foundusername eq false ) { print "username not found!<br>"; } if ($foundpassword eq false) { print "bad password!<br>"; } }

In reply to Re: Re: Serving an html page by lfindle
in thread Serving an html page by Anonymous Monk

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.