Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Next Page gets downloaded in Perl

Reply
Thread Tools

Next Page gets downloaded in Perl

 
 
Praki
Guest
Posts: n/a
 
      12-13-2007
Greetings All

I have a Perl file in which i m doing all the operaions in one file
based on the command line arguments.
login.cgi
..
..
..
$query = new CGI;
$sid = $query->cookie('CGISESSID') || $query->param('CGISESSID') ||
undef;
$submit_value=$query->param("submit");

if ($sid ne ""){
print $query->header( -cookie=>$cookie );}
else{
print "Content-type: text/html";}

if ($sid eq "" && $submit_value eq "") {
&auth_page(" Login Authentication"," Login Authentication");
print "Session id: ";
print $sid;
print "\n Submit value:";
print $query->param("submit");

print $FORM{'uid'};
print $query->header( -cookie=>$cookie );
&print_trailer();
exit(0);
}
elsif ($sid eq "" && $submit_valu ne "") {
&print_header(" Login Authentication"," Login Authentication");
&print_trailer();
exit(0);
}
..
..
..
when i open the for the first time it should go to

if ($sid eq "" && $submit_value eq "") this condition as both will be
empty. and here i m getting the login information and again i m
calling the same file(login.cgi). now as the sumbit value will not be
empty it has to go the next condtion

elsif ($sid eq "" && $submit_valu ne "") .i m validating the
credentials here. but the problem here i face is the page info which
is to be displayed in the browser is automaticaly asks for File
Download. when downloaded that file and check by open in the new
window it displays the ouput. i could not understand the problem so
plz can u help me in clearing this problem...

where i m going wrong..
thanks,
Prakash
 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      12-13-2007
On Dec 13, 1:19 am, Praki <visitprakashin...@gmail.com> wrote:
> Greetings All
>
> I have a Perl file in which i m doing all the operaions in one file
> based on the command line arguments.
> login.cgi
> .
> .
> .
> $query = new CGI;
> $sid = $query->cookie('CGISESSID') || $query->param('CGISESSID') ||
> undef;
> $submit_value=$query->param("submit");
>
> if ($sid ne ""){
> print $query->header( -cookie=>$cookie );}
> else{
> print "Content-type: text/html";}
>
> if ($sid eq "" && $submit_value eq "") {
> &auth_page(" Login Authentication"," Login Authentication");
> print "Session id: ";
> print $sid;
> print "\n Submit value:";
> print $query->param("submit");
>
> print $FORM{'uid'};
> print $query->header( -cookie=>$cookie );
> &print_trailer();
> exit(0);}
>
> elsif ($sid eq "" && $submit_valu ne "") {
> &print_header(" Login Authentication"," Login Authentication");
> &print_trailer();
> exit(0);}
>
> .
> .
> .
> when i open the for the first time it should go to
>
> if ($sid eq "" && $submit_value eq "") this condition as both will be
> empty. and here i m getting the login information and again i m
> calling the same file(login.cgi). now as the sumbit value will not be
> empty it has to go the next condtion
>
> elsif ($sid eq "" && $submit_valu ne "") .i m validating the
> credentials here. but the problem here i face is the page info which
> is to be displayed in the browser is automaticaly asks for File
> Download. when downloaded that file and check by open in the new
> window it displays the ouput. i could not understand the problem so
> plz can u help me in clearing this problem...
>
> where i m going wrong..


Your content-type header is wrong. It's missing newlines. You're
using the $query->header() method in the if statement. Why not in the
else statement?

if ($sid ne ""){
print $query->header( -cookie=>$cookie );
}
else{
print $query->header( );
}

(A completely separate problem is that you're later trying to print
the header with some cookies, after you've already printed both header
and content. That's not going to work. You need to rework your
logic).

Paul Lalli
 
Reply With Quote
 
 
 
 
Praki
Guest
Posts: n/a
 
      12-13-2007
On Dec 13, 6:44 pm, Paul Lalli <mri...@gmail.com> wrote:
> On Dec 13, 1:19 am, Praki <visitprakashin...@gmail.com> wrote:
>
>
>
> > Greetings All

>
> > I have a Perl file in which i m doing all the operaions in one file
> > based on the command line arguments.
> > login.cgi
> > .
> > .
> > .
> > $query = new CGI;
> > $sid = $query->cookie('CGISESSID') || $query->param('CGISESSID') ||
> > undef;
> > $submit_value=$query->param("submit");

>
> > if ($sid ne ""){
> > print $query->header( -cookie=>$cookie );}
> > else{
> > print "Content-type: text/html";}

>
> > if ($sid eq "" && $submit_value eq "") {
> > &auth_page(" Login Authentication"," Login Authentication");
> > print "Session id: ";
> > print $sid;
> > print "\n Submit value:";
> > print $query->param("submit");

>
> > print $FORM{'uid'};
> > print $query->header( -cookie=>$cookie );
> > &print_trailer();
> > exit(0);}

>
> > elsif ($sid eq "" && $submit_valu ne "") {
> > &print_header(" Login Authentication"," Login Authentication");
> > &print_trailer();
> > exit(0);}

>
> > .
> > .
> > .
> > when i open the for the first time it should go to

>
> > if ($sid eq "" && $submit_value eq "") this condition as both will be
> > empty. and here i m getting the login information and again i m
> > calling the same file(login.cgi). now as the sumbit value will not be
> > empty it has to go the next condtion

>
> > elsif ($sid eq "" && $submit_valu ne "") .i m validating the
> > credentials here. but the problem here i face is the page info which
> > is to be displayed in the browser is automaticaly asks for File
> > Download. when downloaded that file and check by open in the new
> > window it displays the ouput. i could not understand the problem so
> > plz can u help me in clearing this problem...

>
> > where i m going wrong..

>
> Your content-type header is wrong. It's missing newlines. You're
> using the $query->header() method in the if statement. Why not in the
> else statement?
>
> if ($sid ne ""){
> print $query->header( -cookie=>$cookie );}
>
> else{
> print $query->header( );
>
> }
>
> (A completely separate problem is that you're later trying to print
> the header with some cookies, after you've already printed both header
> and content. That's not going to work. You need to rework your
> logic).
>
> Paul Lalli


Thanks for that info i corected and its working fine....
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Return of gets gets John Joyce Ruby 0 04-23-2007 01:38 PM
gets gets John Joyce Ruby 2 03-26-2007 04:00 PM
Perl 5.00404 - Label not found for "next " , next() function Liora Perl Misc 5 01-12-2007 03:36 AM
Not only the selected HREF gets surrounded, but the whole row gets surrounded Stefan Mueller HTML 5 07-10-2006 11:53 AM
CurrentElement->next = CurrentElement->next->next (UNDEFINED?) Deniz Bahar C Programming 2 03-09-2005 12:45 AM



Advertisments