Hello guys,
I tried to make a simple login script that prints “Welcome to duty admin” if the username that the user typed is “admin”. Otherwise, the message would be “Unauthorized”. Nonetheless, I can’t figure out why it gives me an error when I first run the script.
This is the code:
[code=html]<html>
<head>
<title>A BASIC HTML FORM</title>
<?PHP
$user = $_POST[‘Username’];
if ($user == “admin”) {
print (“Welcome to duty admin”);
}
else {
print(“You are not allowed here”);
}
?>
</head>
<body>
<FORM NAME =”form1″ METHOD =”Post” ACTION = “basicForm.php”>
<input type=”Text” name=”Username” value=”Username”>
<input type=”Submit” name=”Submit1″ value=”Login”>
</FORM>
</body>
</html>
The error:
Notice: Undefined index: Username in C:wampwwwbasicForm.php on line 5
Call Stack
1 0.0000 139824 {main}( ) ..basicForm.php:0
P.S: It also says “Unauthorized” at the beginning even though I haven’t pressed the Login button.
Thanks!