PHP help
Posted: Thu Nov 17, 2011 1:20 pm
Hi, I'm trying to write some basic PHP to allow a user to enter their username in a website, and then maintain a session throughout, or until the user selects 'logout'. I've only done a very small amount of PHP in the past, and that was roughly two years ago, so any help would be much appreciated.
Basically, so far, I have two files: index.html and home.php
index.html looks like this:
When I view index.html in the browser, I can enter a username into a text box, and click a 'submit' button. When I click the 'submit' button, I am taken to the 'home' page, which should display a message saying "Welcome <username> !"
However, at the moment, the 'home' page just displays "Welcome !"
Can anyone tell me what I'm doing wrong, and what I need to do to get the username to be displayed on the 'home' page, and any subsequent pages?
Thanks in advance!
Basically, so far, I have two files: index.html and home.php
index.html looks like this:
Code: Select all
<html>
<body>
<form action="home.php" method="post">
Name: <input type="text" name="userName" />
<input type="submit" />
</form>
</body>
</html>
and home.php looks like this:
<html>
<body>
Welcome <?php echo $_POST["userName"]; ?>!
</body>
</html>However, at the moment, the 'home' page just displays "Welcome !"
Can anyone tell me what I'm doing wrong, and what I need to do to get the username to be displayed on the 'home' page, and any subsequent pages?
Thanks in advance!