Hi!
In the following code-
<?php
header('Cache-Control:no-cache');
?>
<!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>
<form id="form1" name="form1" method="post" action="<?php echo($_SERVER['PHP_SELF']);?>">
<p>
<label>Name:
<input type="text" name="txt" id="txt" value="<?php $_POST['txt'];?>" />
</label></p>
<p>
<input type="submit" name="b1" id="b1" value="Submit" />
</p>
</form>
<hr />
<?php
//form handler
if(isset($_POST['b1']))
{
echo($_POST['txt']);
}
else
{
echo("Enter a value");
}
?>
</body>
</html>
in this form, i am not able to understand why we have to use the value attribute for the textfield-
<input type="text" name="txt" id="txt" value="<?php $_POST['txt'];?>" />
don't we know that the $_POST variable refers to the value of the textfield? so why set the value attribute again?