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.
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') );