NEWBIE: Perl CGI script that redirects to another webpage

Discussion in 'Perl Misc' started by Tester, Jan 4, 2005.

  1. Tester

    Tester Guest

    Hi There,

    I think this is very simple. I need to write a PERL script that a form is
    submitted to it, one of the forms input parameters is a URL.

    Once the script has done some other processing, it redirects the users
    browser to the URL.

    E.g.
    Webpage is Form submission.
    User presses submit and it sends over form details including one (hidden)
    field called URL
    PERL script processes the form and then redirects browser to the URL field

    I hope that makes sense and I am sure that is easy to do but I am not sure
    how.

    Kind regards and thanks in advance.

    Dave
    Tester, Jan 4, 2005
    #1
    1. Advertising

  2. Tester

    Matt Garrish Guest

    "Tester" <SPAM FREE WORLD> wrote in message
    news:41db2985$...
    > Hi There,
    >
    > I think this is very simple. I need to write a PERL script that a form is
    > submitted to it, one of the forms input parameters is a URL.
    >
    > Once the script has done some other processing, it redirects the users
    > browser to the URL.
    >


    Please see the perlfaqs for why you should never write PERL.

    I have no idea why you would pass the final url around in a hidden field,
    but the solution to your problem lies with the http header you send. Print
    the correct ***redirect*** to that url and all will be well...

    Googling on "perl cgi redirect" will also show you that this question has
    been answered many, many times now.

    Matt
    Matt Garrish, Jan 4, 2005
    #2
    1. Advertising

  3. Tester <> wrote:

    > Subject: NEWBIE: Perl CGI script that redirects to another webpage



    Have you seen the Posting Guidelines that are posted here frequently?


    > I think this is very simple.



    Then you should look for it in the Perl FAQ *before* posting
    to the Perl newsgroup!


    > Once the script has done some other processing, it redirects the users

    ^^^^^^^^
    > browser to the URL.



    perldoc -q redirect

    How do I redirect to another page?


    --
    Tad McClellan SGML consulting
    Perl programming
    Fort Worth, Texas
    Tad McClellan, Jan 5, 2005
    #3
  4. Tester

    Tintin Guest

    "Tester" <SPAM FREE WORLD> wrote in message
    news:41db2985$...
    > Hi There,
    >
    > I think this is very simple. I need to write a PERL script that a form is
    > submitted to it, one of the forms input parameters is a URL.
    >
    > Once the script has done some other processing, it redirects the users
    > browser to the URL.
    >
    > E.g.
    > Webpage is Form submission.
    > User presses submit and it sends over form details including one (hidden)
    > field called URL
    > PERL script processes the form and then redirects browser to the URL field
    >
    > I hope that makes sense and I am sure that is easy to do but I am not sure
    > how.
    >
    > Kind regards and thanks in advance.


    #!/usr/bin/perl
    use strict;
    use CGI;

    my $q = new CGI;
    my $url=$q->param('url');
    print $q->redirect($url);
    Tintin, Jan 5, 2005
    #4
    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. Derek Basch

    CGI and HTTP Header Location redirects

    Derek Basch, Feb 4, 2005, in forum: Python
    Replies:
    1
    Views:
    523
    Paul Rubin
    Feb 4, 2005
  2. Derek Basch
    Replies:
    0
    Views:
    334
    Derek Basch
    Feb 4, 2005
  3. Derek Basch
    Replies:
    1
    Views:
    302
    Paul Rubin
    Feb 5, 2005
  4. Replies:
    20
    Views:
    696
    Gunnar Hjalmarsson
    Jan 18, 2005
  5. kath
    Replies:
    4
    Views:
    560
    J. Gleixner
    Apr 9, 2007
Loading...

Share This Page