I am self studying newbie to PHP.
I would like to run a small PHP script only if the submit button is clicked. Unfortunately the function isset()
that (according to my tutorial lesson) performs this submit button check -does not seem to be working !
When I refresh the page in the browser, part of the PHP script: print("You're not a member of this site");
is still getting executed even though I have not yet pressed the submit button! Why?
and the code:
<html>
<head>
<title>A BASIC HTML FORM</title>
<?PHP
if (isset($_POST['Submit1'])) {
$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">
<p>
<Input Type = "Submit" Name = "Submit1" Value = "Login">
</FORM>
</body>
</html>