View previous topic :: View next topic |
Author |
Message |
sean -
Joined: 29 Jan 2004 Posts: 18 Location: London
|
Posted: Thu Feb 12, 2004 11:34 pm Post subject: Please Read and HELP! |
|
|
Hey all,
I'm pretty new to this so bear with me...
How can i retrieve data from a form with CGI? For example, someone puts in the name, then press submit - how do i get the next page to say "Welcome (name)!"
Any help would be appreciated :)
Sean \m/ |
|
Back to top |
|
|
nquin321 -
Joined: 29 Jan 2004 Posts: 296 Location: Right Behind You
|
|
Back to top |
|
|
sean -
Joined: 29 Jan 2004 Posts: 18 Location: London
|
Posted: Fri Feb 13, 2004 5:38 pm Post subject: Ummmm |
|
|
Hey thanks, but i know there is a way to do it with CGI - and i'm learning CGI, so i would like to do it with that....
Thanks anyway. |
|
Back to top |
|
|
aprelium -
Joined: 22 Mar 2002 Posts: 6800
|
Posted: Sun Feb 15, 2004 4:51 pm Post subject: Re: Please Read and HELP! |
|
|
sean,
Here is an example in Perl. Install Perl as described in http://www.aprelium.com/abyssws/perl.html .
Save this HTML code file as hello.html:
Code: | <HTML>
<HEAD>
<TITLE>Hello</TITLE>
</HEAD>
<BODY>
<FORM ACTION = "hello.pl" METHOD ="GET">
What's your name: <INPUT TYPE="text" NAME="name" SIZE="20" VALUE="Enter your Name"><BR>
<BR>
<INPUT TYPE="submit" VALUE ="click here">
</FORM>
</BODY>
</HTML>
|
Then save this Perl code as hello.pl:
Code: |
use CGI;
$query = new CGI;
# set an appropriate From: address
$yourname = $query->param('name');
print "Content-type: text/html\n\n";
print <<"EOF";
<HTML>
<HEAD>
<TITLE>Hello</TITLE>
</HEAD>
<BODY>
<P>Hello $yourname</P>
</BODY>
</HTML>
EOF
;
|
Put both files in your htdocs/ directory and browse http://yousite/hello.html . _________________ Support Team
Aprelium - http://www.aprelium.com |
|
Back to top |
|
|
sean -
Joined: 29 Jan 2004 Posts: 18 Location: London
|
Posted: Mon Feb 16, 2004 6:50 pm Post subject: Hey, thanks for that |
|
|
Thanks for that Aprelium. It helped a lot. I also found a new way to do it, at the top of my pages i put:
require "cgi-lib.pl";
&ReadParse(*input);
$uname= $input{'name'};
and then in my document i put
print "Hello $uname";
and it works fine. :) Thank you |
|
Back to top |
|
|
|