02-15-2012
problem with exporting vairable from one perl cgi to another perl cgi script while redirecting.
Can anyone tell me how to export a variable from one perl CGI script to another perl cgi script when using a redirect.
Upon running the login.pl the user is prompted to enter user name and password. Upon entering the correct credentials (admin/admin) the user is
redirected to welcome page.
My requirement is, the welcome page should display the username. "Hello, admin"
Note: I dont want to use cookies.
Any help is highly appreciated...
Thanks in advance...
-Arun
Here is my first CGI script login.pl:
====================================
#!/perl/bin/perl -wT
#login.pl
use warnings;
use CGI::Pretty qw(:all);
use strict;
my $cgi=new CGI;
my $username=$cgi->param('username');
my $password=$cgi->param('password');
my $db_username="admin";
my $db_password="admin";
if ( $username eq $db_username && $password eq $db_password ) {
print $cgi->redirect("http://localhost/welcome.pl");
}else {
print header();
print start_html(-title=>"Login");
if ($cgi->param('username') or $cgi->param('password')) {
print center(font({-color=>'red'},"Invalid input"));
}
print generate_form();
print end_html();
}
sub generate_form {
return start_form,
h1("Please Login"),
p("username", textfield('username')),
p("password", textfield('password')),
p(submit),
end_form;
}
Here is my second script:
===========================
#!/perl/bin/perl -wT
#welcome.pl
use warnings;
use CGI::Pretty qw(:all);
use strict;
my $cgi=new CGI;
my $username;
print header();
print start_html("Welcome"),h1("Hello, $username");
print end_html();
10 More Discussions You Might Find Interesting
1. Web Development
Hi,
I am writing a perl script using Perl CGI. There are various HTML tables and forms involved in this. Now I wanted to add a tool tip to the elements here but I am not able to find documentation on how to do it. Can anyone help?
Thanks in advance.
Regards,
garric (5 Replies)
Discussion started by: garric
5 Replies
2. Shell Programming and Scripting
hi,,
i have perl scipt with line :
system('./try.sh $t $d $m');
in shell scipt try.sh i have the line:
echo $1
its not printing value of $t that i hav passed..y is it so..i am running it from apache web server (2 Replies)
Discussion started by: raksha.s
2 Replies
3. Web Development
hi,i hav a form in cgi perl script.this script accepts a value from user from another html form, and depending upon this value,i need to disable /enable radio buttons in cgi-perl script wen second page is displayed on executing cgi perl script.how do i do it using javascript? (0 Replies)
Discussion started by: raksha.s
0 Replies
4. Web Development
Hello,
Met a problem learning perl cgi script.
1 #!/usr/bin/perl -wT
2
3 use strict;
4 use CGI qw(:standard);
5
6 my $q = new CGI;
7
8 my $filename = $q->param('/home/yifangt/hello.cgi');
9 my $contenttype = $q->uploadInfo($filename)->{'Content-Type'};
10... (5 Replies)
Discussion started by: yifangt
5 Replies
5. Shell Programming and Scripting
I am trying to run SSH , mkdir and other unix commands using Perl CGI. But i am not able to Execute these commands.
Please help me out !!!!
SSH and mkdir is necessity for me.
I will be thankful to you...!!!!!
I am trying like:
In perl CGI file i am writing like: @list = `ssh... (28 Replies)
Discussion started by: Navrattan Bansa
28 Replies
6. Shell Programming and Scripting
Hi All,
I am aware that html tags can be embedded in cgi script as below.. In the same way is it possible to embed the below javascript in perl cgi script ??
print("<form action="action.htm" method="post" onSubmit="return submitForm(this.Submitbutton)">");
print("<input type = "text"... (1 Reply)
Discussion started by: scriptscript
1 Replies
7. Shell Programming and Scripting
Hi team,
I have a typical problem with cgi pages in apache webserver in WINDOWS
I am able to execute(display) the pages that are saved in cgi-bin folder.
But I am not able to execute the pages stored in htdocs or other folder other than cgi-bin folder.
Could anyone please let me know how... (1 Reply)
Discussion started by: scriptscript
1 Replies
8. Shell Programming and Scripting
Hi All,
I have written an cgi perl script that displays an image(Excel image) and when clicked on that Image I need to download a excel sheet.
I made sure that excel sheet exists in the folder with the given name but still I am not able to download the sheet.
print "<center><table... (2 Replies)
Discussion started by: scriptscript
2 Replies
9. Shell Programming and Scripting
Hi Team,
I am trying to connect to database(succeeded ) and print the records on the browser using while loop. But the elements of array are not displayed instead while loop is displayed directly. Instead of the below I can embed html statements in print but I am looking for the below style as I... (1 Reply)
Discussion started by: scriptscript
1 Replies
10. Shell Programming and Scripting
Hello experts,
I am facing an very typical problem and hope the issue can be solved.
I have a page download.cgi in /cgi-bin folder.
use CGI;
use CGI::Carp qw ( fatalsToBrowser );
use File::Copy
copy("C:\\Program Files\\Apache Software... (8 Replies)
Discussion started by: scriptscript
8 Replies
LEARN ABOUT CENTOS
appconfig::cgi
AppConfig::CGI(3) User Contributed Perl Documentation AppConfig::CGI(3)
NAME
AppConfig::CGI - Perl5 module for processing CGI script parameters.
SYNOPSIS
use AppConfig::CGI;
my $state = AppConfig::State->new(\%cfg);
my $cgi = AppConfig::CGI->new($state);
$cgi->parse($cgi_query);
$cgi->parse(); # looks for CGI query in environment
OVERVIEW
AppConfig::CGI is a Perl5 module which implements a CGI interface to AppConfig. It examines the QUERY_STRING environment variable, or a
string passed explicitly by parameter, which represents the additional parameters passed to a CGI query. This is then used to update
variable values in an AppConfig::State object accordingly.
AppConfig::CGI is distributed as part of the AppConfig bundle.
DESCRIPTION
USING THE AppConfig::CGI MODULE
To import and use the AppConfig::CGI module the following line should appear in your Perl script:
use AppConfig::CGI;
AppConfig::CGI is used automatically if you use the AppConfig module and create an AppConfig::CGI object through the cgi() method.
AppConfig::CGI is implemented using object-oriented methods. A new AppConfig::CGI object is created and initialised using the new()
method. This returns a reference to a new AppConfig::CGI object. A reference to an AppConfig::State object should be passed in as the
first parameter:
my $state = AppConfig::State->new();
my $cgi = AppConfig::CGI->new($state);
This will create and return a reference to a new AppConfig::CGI object.
PARSING CGI QUERIES
The "parse()" method is used to parse a CGI query which can be specified explicitly, or is automatically extracted from the "QUERY_STRING"
CGI environment variable. This currently limits the module to only supporting the GET method.
See AppConfig for information about using the AppConfig::CGI module via the cgi() method.
AUTHOR
Andy Wardley, "<abw@wardley.org<gt">
COPYRIGHT
Copyright (C) 1997-2007 Andy Wardley. All Rights Reserved.
Copyright (C) 1997,1998 Canon Research Centre Europe Ltd.
This module is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
SEE ALSO
AppConfig, AppConfig::State
perl v5.16.3 2007-05-30 AppConfig::CGI(3)