Reputation: 1137
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.
Upvotes: 1
Views: 2958
Reputation: 23085
I don't think that PHP will work, but I'm not a PHP developer. If you gave the error it would help, but I think you need to quote the string.
print $cgi->redirect(
-uri => "http://www.yoursite.com/new_page.pl?user_name=$username",
-status => 303,
-cookie => $c,
);
You should add the following two lines (enabling the strict and warnings pragmas) to the top of your script, they would have helped you debug the issue:
use strict;
use warnings;
For the record, I think the PHP example should use double quotes:
header( "Location: http://www.yoursite.com/new_page.php?user_name=$username" );
Upvotes: 1
Reputation: 13792
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') );
Upvotes: 4