form isn't passing variable

jlknauff

New member
Aug 25, 2008
237
1
0
Any idea why the data entered in the text area never ends up getting passed to the variable here?

PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
</head>
<body>

<?php
if (isset($_POST["field"])) {
echo $field;
?>
    <a href="<?php echo $_SERVER[PHP_SELF]; ?>"><p><?php echo $field; ?></p></a>


</body>
</html>

<?php
die();
}

else

?>

    <form action="<?php echo $_SERVER[PHP_SELF]; ?>" method="post" >
    <textarea name="field" rows="10" cols="30" ></textarea>
    <input type="submit" value="Submit" />
    </form>
</body>
</html>
 


The $field variable is empty at the moment, you need the following:

PHP:
<?php
if (isset($_POST["field"])) {
$field = $_POST['field'];
echo $field;
?>