HTML Tutorial


 Forum HomeForum Home   FAQFAQ   SearchSearch   MemberlistMemberlist   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
RegisterRegister - Not registered yet? Got something to say? Join HTML Code Tutorial!
Carrying one field to another
Post new topic   Reply to topic    HTML Help Forum Index -> HTML Form
View previous topic :: View next topic  
Author Message
anton



Joined: 12 Feb 2008
Posts: 3

PostPosted: Fri Mar 14, 2008 8:53 am     Carrying one field to another Reply with quote

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

PostPosted: Tue Mar 18, 2008 9:01 am     Re: Carrying one field to another Reply with quote

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>
Display posts from previous:   
Post new topic   Reply to topic    HTML Help Forum Index -> HTML Form All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
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
HTML Help Archive
Powered by phpBB © 2001, 2005 phpBB Group
HTML Help topic RSS feed 

 
HOSTING / DESIGN
MAKE MONEY

Home
  |   Tutorials   |   Forum   |   Quick List   |   Webmaster Directory   |   About
Copyright ©1997-2002 Idocs and ©2002-2007 HTML Code Tutorial