mrudul
10-16-2011, 12:11 PM
Hi,
I am a beginner on PHP.
I am writing a script to check if the Login button is pressed and calling another PHP script to perform this task, for that I have written 2 script i.e. basicForm2.php and submitForm.php.
While executing the script it is giving an error:
"( ! ) Notice: Undefined variable: username in C:\wamp\www\basicForm2.php on line 11 Call Stack #TimeMemoryFunctionLocation 10.0013363320{main}( )..\basicForm2.php:0 "> "
The script is as follows:
1. basicForm2.php:
<html>
<head>
<title>A BASIC HTML FORM</title>
</head>
<body>
<FORM NAME ="form1" METHOD ="POST" ACTION="submitForm.php">
<INPUT TYPE = "TEXT" Name = 'username' VALUE="<?PHP print $username ; ?>">
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login">
</FORM>
</body>
</html>
2. submitForm.php:
<?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");
}
}
else {
$username ="";
}
?>
Please help me to resolve this issue.
Thanks in advance,
Mrudul
I am a beginner on PHP.
I am writing a script to check if the Login button is pressed and calling another PHP script to perform this task, for that I have written 2 script i.e. basicForm2.php and submitForm.php.
While executing the script it is giving an error:
"( ! ) Notice: Undefined variable: username in C:\wamp\www\basicForm2.php on line 11 Call Stack #TimeMemoryFunctionLocation 10.0013363320{main}( )..\basicForm2.php:0 "> "
The script is as follows:
1. basicForm2.php:
<html>
<head>
<title>A BASIC HTML FORM</title>
</head>
<body>
<FORM NAME ="form1" METHOD ="POST" ACTION="submitForm.php">
<INPUT TYPE = "TEXT" Name = 'username' VALUE="<?PHP print $username ; ?>">
<INPUT TYPE = "Submit" Name = "Submit1" VALUE = "Login">
</FORM>
</body>
</html>
2. submitForm.php:
<?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");
}
}
else {
$username ="";
}
?>
Please help me to resolve this issue.
Thanks in advance,
Mrudul