linuxStat PHP Documentation

Collection of data from a textarea in a form

A textarea is used to enter multiple lines of text.
It has the following appearance in a web form.

Your feedback on this book:



The user types in how useful she found this book for her work then
she presses the Submit button.


An HTML document containing the above textarea element is the following.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/transitional.dtd">
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<title>Executed on Dell Server, Intel Processor, created on HP laptop</title>
</head>
<body bgcolor="#6B7E23" text="#FFFF00" lang=EN-US>
<form action="echofeedback.php" method="get">
Your feedback on this book:<br>
<textarea name="feedback" cols="60" rows="20"></textarea>
<br><br>
<input type="submit" name="Submit" value="Submit" size="30" />
</form>
</body>
</html>

When the user presses the Submit button, the PHP interpreter
executes a PHP program contained in the file echofeedback.php.
Before the PHP program in echofeedback.php is executed, a map
called _GET is constructed. The text typed in by the user is the value
given by the name feedback in the _GET map. Thus,
$_GET["feedback"]
will give the text typed in by the user.

We will construct a PHP program that will echo back the text typed
in by the user as follows and save it in echofeedback.php file.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/transitional.dtd">
<html>
<head>
<meta http-equiv=Content-Type content="text/html; charset=us-ascii">
<title>Executed on Dell Server, Intel Processor, created on HP laptop</title>
</head>
<body bgcolor="#6B7E23" text="#FFFF00" lang=EN-US>
<?php
# Example of textarea data in _GET map
print "You typed in: {$_GET["feedback"]} <br>";
?>
</body>
</html>


Click the following link to execute the above PHP code
by my server's PHP interpreter. Notice the text returned by echofeedback.php.
This is exactly how echofeedback.php sees the text you entered.

Try the above example   Next   Index