Jump to: navigation, search

PHP HTML TextArea

From w3cyberlearnings

Contents

PHP Works with HTML Textarea

HTML Textarea tag uses for multiple line text input.

Syntax Textarea

<textarea name="mytest" rows="40" cols="40">My Default Text Area</textarea>

Example 1

<?php
if ($_POST) {
print_r($_POST);
}
?>
<html>
<head>
<title>Textarea</title>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post">
	<i>Information</i><br/>
	<textarea name="description" rows="5" cols="40"></textarea><br/>
	<input type="submit"/>
</form>
</body>
</html>

Output

Php form textarea 1.png

Example 2

<?php
$msg = "";
if (!empty($_POST['SAVE'])) {
$msg .= 'Name: ' . $_POST['NAME'] . '<br/>';
$msg .= 'Description: ' . $_POST['DESCRIPTION'] . '<br/>';
}
?>
<html>
<head>
<title>Textarea form</title>
</head>
<body>
<?php echo $msg; ?>
<hr/>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="POST">
<table>
	<tr>
		<td valign="top">Name:</td>
		<td><input type="text" name="NAME"  size="20" maxlength="20"/></td>
	</tr>
	<tr>
		<td valign="top">Description:</td>
		<td><textarea name="DESCRIPTION" rows="5" cols="40"></textarea></td>
	</tr>
	<tr><td colspan="2"><input type="submit" name="SAVE" value="Save It"></td></tr>
</table>
</form>
</body>
</html>

Output

Php form textarea 2.png

Related Links


  1. HTML POST
  2. HTML GET
  3. HTML Textarea
  1. HTML Hidden Field
  2. HiddenField Multiple Pages
  3. HTML Password
  1. HTML Textbox
  2. HTML Checkbox
  3. HTML Radio
  1. Drop down list
  2. Pass value uses URL
  3. Pass value uses URL 2.
  4. Multiple Submit Buttons
Navigation
Web
SQL
MISC
References