加载没有任何 GET 参数的页面时出现错误(例如:/login.php),这是我得到的错误:
( ! ) Notice: Undefined index: err in C:\wamp\www\GestionImagesPublicitesAvis\login.php on line 57
Call Stack
# Time Memory Function Location
1 0.0005 144120 {main}( ) ..\login.php:0
这是第 41 行到第 58 行的代码片段:
<input class=
<?php if(!empty($err))
{
if($err == "up")
{
echo "\"InputError\"";
}
else
{
echo "\" \"";
}
}
else
{
echo "\" \"";
} ?>
type="text" name="username" onclick="this.value='';" onblur="this.value=!this.value?'login...':this.value;" value=<?php if (($_GET['err'] == 'up')&& (isset($_GET['u']))){echo ("\"" . $_GET['u'] . "\"");}else{ echo "\"login...\"";} ?> id="username"/>
<input class=<?php if($err=="up"){echo "\"InputError\"";}else{echo "\"\"";}?> type="password" name="password" onclick="this.value='';" onblur="this.value=!this.value?'motdepasse':this.value;" value="motdepasse" id="password"/>
$err 在页面前面定义(第 15 行):`
<?php
$err;
if (isset($_GET['err']))
{
switch ($_GET['err'])
{
case "up":
$err = "up";
echo "<p>Error #156</p>";
break;
}
}
else
{
$err=null;
echo "<p>Error #157</p>";
}
?>