How to keep data that the user entered?
Posted: Wed Jan 06, 2010 4:38 pm
Hello,
When I try to retrieve data that inserted to the text area, it didn't keep the value.
Here's the code (the retrieve function is bold)
<html>
<head>
<title>A BASIC HTML FORM</title>
<?PHP
$username = $_POST['username'];
if (isset($_POST['Submit1']))
{
$username = $_POST['username'];
if ($username == "myFriend")
{
print ("Welcome back, friend!");
}
}
else
{
$username="";
}
?>
</head>
<body>
<FORM NAME ="form1" METHOD ="POST" ACTION = "http://localhost/try3.php">
<INPUT TYPE = 'TEXT' VALUE ="<?PHP print $username;?>" NAME ='username'>
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login">
</FORM>
</body>
</html>
When I try to retrieve data that inserted to the text area, it didn't keep the value.
Here's the code (the retrieve function is bold)
<html>
<head>
<title>A BASIC HTML FORM</title>
<?PHP
$username = $_POST['username'];
if (isset($_POST['Submit1']))
{
$username = $_POST['username'];
if ($username == "myFriend")
{
print ("Welcome back, friend!");
}
}
else
{
$username="";
}
?>
</head>
<body>
<FORM NAME ="form1" METHOD ="POST" ACTION = "http://localhost/try3.php">
<INPUT TYPE = 'TEXT' VALUE ="<?PHP print $username;?>" NAME ='username'>
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login">
</FORM>
</body>
</html>