How to keep data that the user entered?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
yb23
Forum Newbie
Posts: 3
Joined: Sat Jan 02, 2010 7:08 pm

How to keep data that the user entered?

Post by yb23 »

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>
aravona
Forum Contributor
Posts: 347
Joined: Sat Jun 13, 2009 3:59 pm
Location: England

Re: How to keep data that the user entered?

Post by aravona »

is this the first time someone enters in a username? or do you have them stored on a database?

Is this like a 'remember me' function of a user log in?
Post Reply