Page 1 of 1

Could use some help understanding this code

Posted: Wed Jul 14, 2010 3:01 pm
by Deewr
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:

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>


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!

Re: Could use some help understanding this code

Posted: Wed Jul 14, 2010 3:09 pm
by yacahuma
The name of your button is submit1 instead of submit. When you check you isset, the names most be the same

Re: Could use some help understanding this code

Posted: Wed Jul 14, 2010 5:30 pm
by Deewr
Thank you. It's always something so simple and obvious, isn't it?