<html>
<head>
<title>A BASIC HTML FORM</title>
<?PHP
$username = $_POST['username'];
print ($username);
?>
</head>
<body>
<FORM NAME ="form1" METHOD ="POST" ACTION = "try2.php">
<INPUT TYPE = "TEXT" VALUE ="username" NAME ="username">
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login">
</FORM>
</body>
</html>
this code suppose to print the word "username"
and in the line below- the input area and "login" button.
why it doesn't work?
thanks.
code doesn't work
Moderator: General Moderators
- SimpleManWeb
- Forum Commoner
- Posts: 57
- Joined: Wed Dec 30, 2009 4:15 pm
- Location: New Hampshire, USA
Re: code doesn't work
You are posting to try2.php. Based off of the code, it looks like you actually want to post directly to this PHP file, so just set the "action" parameter to nothing and it will post back to itself.
Re: code doesn't work
yes, but it's still doesn't work, the code should view the screen like the attached picture.
- Attachments
-
- basicFormPost2.jpg (22.7 KiB) Viewed 31 times
Re: code doesn't work
Try this:
isset is described here http://www.php.net/manual/en/function.isset.php
Also added and modified some code in the form to complete the syntax.
Regards,
Bill Antonacchio
Code: Select all
<html>
<head>
<title>A BASIC HTML FORM</title>
<?PHP
if (isset($_POST['username'])) {
$username = $_POST['username'];
print ($username);
}
?>
</head>
<body>
<FORM NAME ="form1" METHOD ="POST" ACTION = "try2.php">
<label for="username">username</label>
<INPUT="username" TYPE = "TEXT" id="username" VALUE ="username" NAME ="username">
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login"></p>
</FORM>
</body>
</html>
Also added and modified some code in the form to complete the syntax.
Regards,
Bill Antonacchio