 |
|
|
| View previous topic :: View next topic |
| Author |
Message |
anton
Joined: 12 Feb 2008 Posts: 3
|
Posted: Fri Mar 14, 2008 8:53 am Carrying one field to another |
|
|
|
I didnt completely under a tutorial I found a while ago and lost the link to it, so can anyone explain this to me:
How is it possible to get the text typed in a field named "username" to show up as plain text in another page upon clicking a button? |
|
kanenas

Joined: 14 Dec 2004 Posts: 191
|
Posted: Tue Mar 18, 2008 9:01 am Re: Carrying one field to another |
|
|
|
| anton wrote: |
| I didnt completely under a tutorial I found a while ago and lost the link to it, so can anyone explain this to me: |
This very site has a brief explanation of CGI which links to "CGI Made Really Easy". To that I would add the original CGI documentation. Read them over for a better understanding of CGI.
| anton wrote: |
| How is it possible to get the text typed in a field named "username" to show up as plain text in another page upon clicking a button? |
It's possible because computers can send data to each other over a network, and programs can take input and produce output.
Assuming you meant "How do you" rather than "How is it possible to", the exact method depends on what language you use to handle the form. I'm also assuming by "another page" you mean the page returned by the form handler, as opposed to e.g. a page currently opened in another window. Every language gives you access to form fields in a different way. Perl has its CGI module, as does Ruby; JSP uses request.getParameter; in PHP, there's $_REQUEST and $_FILES. Failing any of those, you can usually get form data from the QUERY_STRING environment variable or from standard input.
example form:
| Code: |
<html> <head>
<title>A Trivial Form</title>
</head>
<body>
<form action='handler' method='GET'>
<input name='username' />
<input type='submit' value='Login' />
</form>
</body> </html> |
example form handler in Perl (named 'handler.cgi' or '/cgi-bin/handler'):
| Code: |
#! /usr/bin/perl
use CGI;
$cgi=new CGI;
print $cgi->header,
$cgi->start_html('A Trivial Form Handler'),
"Your username is ", $cgi->param('username'),
$cgi->end_html;
|
example form handler in PHP (named 'handler.php'):
| Code: |
<html> <head>
<title>A Trivial Form Handler</title>
</head>
<body>
Your username is: <?php
echo $_REQUEST['username'];
?></body> </html>
|
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
|
|
|
|
 |
|
|
|
|
|
|
|