Could use some help understanding this code
Posted: Wed Jul 14, 2010 3:01 pm
Hello, newbie here. I just starting teaching (or trying to) myself Php. I have WAMP set up on my computer to test the codes I'm learning.
I have a simple piece of code involving a form that is not doing what the tutorial (one I found online) says it should do.
I entered the following:
I get the submit box, but nothing happens with the if -else statements when I enter a username. No errors either, unless I remove the closing ?>, which incidentally was NOT in the original tutorial. When I left it off, I got a syntax error. Also, I got results before adding the "isset" statement. Any ideas why this code doesn't yield any results?
Thanks!
I have a simple piece of code involving a form that is not doing what the tutorial (one I found online) says it should do.
I entered the following:
Code: Select all
<html>
<head>
<title>A BASIC HTML FORM</title>
<?PHP
if (isset($_POST['Submit'])) {
$username = $_POST['username'];
if ($username=="letmein") {
print ("Welcome back, friend!");
}
else {
print ("You're not a member of this site");
}
}
?>
</head>
<body>
<FORM NAME ="form1" METHOD ="POST" ACTION = "basicForm.php">
<INPUT TYPE = "TEXT" VALUE ="username" NAME = "username">
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login">
</FORM>
</body>
</html>
Thanks!