Perl::CGI Redirect with a Parameter and Access it in the New Page

In PHP it is very common to redirect to a new URL and pass along information such as a 'username.'

<?php

   header( 'Location: http://www.yoursite.com/new_page.php?user_name=$username' ) ;

?>

I can then access the value of 'user_name' in 'new_page.php.'

I can not figure out how to do this using perl.

print $cgi->redirect(-uri=>http://www.yoursite.com/new_page.pl?user_name=$username, -status=>303 , -cookie => $c );

I've tried using my $username = $cgi->param('user_name'), but it's not printing anything.

Thanks.

Answers


You forgot the quotes:

print $cgi->redirect(
         -uri=>"http://www.yoursite.com/new_page.pl?user_name=$username", 
         -status=>303,
         #... 
);

Also, remember escape the username before calling redirect:

my $username = escape( $cgi->param('user_name') );

Need Your Help

I receive an “FirebaseSimpleLogin: An unknown error occurred” in Firebase when I try to log in with Twitter

javascript web twitter-oauth firebase

Yesterday, I discovered Firebase and started to use it. I deployed an edited version (I just changed the CSS) of the chat app provided by Firebase, Everything went OK until I added Twitter Logging

How to browse folders in Objective C?

objective-c xcode osx

I have a folder and inside that, few files. How can i get that files without using any UI classes?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.