LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-17-2010, 11:32 AM   #1
shifter
Member
 
Registered: May 2006
Distribution: Slackware, DragonFly
Posts: 233

Rep: Reputation: 30
passing parameters from cgi script to html page


I have the following problem. I have my script /usr/lib/cgi-bin/login.cgi
and two page in /var/www, home.html and welcome.html.
When I log in /var/www/home.html with email and password, then login.cgi to extract exact user informations from mysql. Now I'd like start welcome.html page from login.cgi and passing user informations trought parameters.
How can I solve this problem?
 
Old 01-17-2010, 11:49 AM   #2
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Hi -

a) it's easy,
... and ...
b) how you *send* the parameters depends on whether you're using "GET" or "POST"
... and ...
c) how you *read* the parameters depends entirely on what language you're using for your CGI script.
 
Old 01-17-2010, 11:57 AM   #3
shifter
Member
 
Registered: May 2006
Distribution: Slackware, DragonFly
Posts: 233

Original Poster
Rep: Reputation: 30
Quote:
b) how you *send* the parameters depends on whether you're using "GET" or "POST"
I'm using GET in home.html. When I log in home.html with email and password, then login.cgi extract users information. I'd like that login.cgi to start welcome.html and to pass this information to home.html. What method or functions I must use in cgi script?

Quote:
c) how you *read* the parameters depends entirely on what language you're using for your CGI script.
I'm using perl for cgi script and html/css for web pages.

Last edited by shifter; 01-17-2010 at 11:58 AM.
 
Old 01-17-2010, 12:08 PM   #4
paulsm4
LQ Guru
 
Registered: Mar 2004
Distribution: SusE 8.2
Posts: 5,863
Blog Entries: 1

Rep: Reputation: Disabled
Cool - great!

Google for "Perl CGI tutorial" - you'll find lots of stuff.

Here's a nice, straightforward example - this actually might be everything you need:

http://en.wikipedia.org/wiki/CGI.pm

Here's another short (but still useful) link:

http://perl.about.com/od/cgiweb/a/perlcgiform.htm

CAVEAT:
"CGI" is by definition "server-side". If you have a website on the Internet, how *much* you can do is limited by what your ISP allows you to do....

PS:
By default, CGI.pm forms use "POST". You can use the "-method" option to explicitly specify "GET" or "POST".

'Hope that helps .. PSM

Last edited by paulsm4; 01-17-2010 at 12:12 PM.
 
Old 01-18-2010, 10:26 AM   #5
theNbomr
LQ 5k Club
 
Registered: Aug 2005
Distribution: OpenSuse, Fedora, Redhat, Debian
Posts: 5,399
Blog Entries: 2

Rep: Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908Reputation: 908
What you are attempting to do is create a 'session'. The concept of sessions is not part of HTTP, and so 'cookies' were invented to support the notion of holding transient values between page loads, so that it becomes possible to do what you are trying to do. You can also pass information between pages by embedding such information in hidden fields in HTML pages. Your CGI will have to grab the values in the hidden fields, and regenerate it as necessary when it builds new pages that are sent to the browser. In Perl and PHP, there are modules available that assist in the creation of sessions using CGI. For Perl, on CPAN, search for 'CGI session'. I don't do PHP, but I have it on good authority that it is similarly straightforward to establish sessions.
--- rod.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Html generated by a CGI page counter script displayed in browser without being parsed gregorian Programming 5 08-19-2009 10:41 AM
Passing parameters to PERL script paddyjoy Programming 3 03-07-2006 11:04 AM
Passing parameters to a shell script neocookie Linux - General 5 10-20-2005 11:44 AM
Passing parameters to bash script Kamikazee Programming 4 10-01-2005 06:41 AM
Passing Parameters to Bash Script mooreted Linux - Software 3 04-05-2004 09:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:57 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration