Next Page gets downloaded in Perl

Discussion in 'Perl Misc' started by Praki, Dec 13, 2007.

  1. Praki

    Praki Guest

    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
     
    Praki, Dec 13, 2007
    #1
    1. Advertising

  2. Praki

    Paul Lalli Guest

    On Dec 13, 1:19 am, Praki <> 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
     
    Paul Lalli, Dec 13, 2007
    #2
    1. Advertising

  3. Praki

    Praki Guest

    On Dec 13, 6:44 pm, Paul Lalli <> wrote:
    > On Dec 13, 1:19 am, Praki <> 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....
     
    Praki, Dec 13, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Stefan Mueller
    Replies:
    5
    Views:
    549
    Steven Saunderson
    Jul 10, 2006
  2. Deniz Bahar
    Replies:
    2
    Views:
    512
    Andrey Tarasevich
    Mar 9, 2005
  3. John Joyce

    gets gets

    John Joyce, Mar 26, 2007, in forum: Ruby
    Replies:
    2
    Views:
    380
    John Joyce
    Mar 26, 2007
  4. John Joyce

    Return of gets gets

    John Joyce, Apr 23, 2007, in forum: Ruby
    Replies:
    0
    Views:
    214
    John Joyce
    Apr 23, 2007
  5. Liora
    Replies:
    5
    Views:
    727
    Tad McClellan
    Jan 12, 2007
Loading...

Share This Page