<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>
<body>
<?php
require("action/login.php");
$loginObj = new login();
?>
<div class= "login_div">
<form id = "login_form" action="action/login.php" method="post" target="temp">
<h5>Name:
<span>
<?php
$loginObj->commitForm();
if(!($loginObj->state)){echo $loginObj->errMassage;}
?>
</span>
</h5>
<input name ="username" type="text">
<input type="submit" >
</form>
<iframe id="temp_iframe" name="temp" style="display:none;"></iframe>
</div>
</body>
</html>
<?php
class login
{
var $errMassage = "";
var $state = false;
var $name = "";
function __construct()
{
$this->name = $_POST["username"];
}
function commitForm()
{
if($this->name == '1234')
{
$this->state = true;
}
else
{
$this->errMassage = "error";
}
return $this->state;
}
}
好……运行index.php,提示“PHP Notice: Undefined index: username in C:\inetpub\wwwroot\Applications\page_A\action\login.php on line 10”
求问,这到底为什么?