我正在尝试使用一些错误消息和类似的东西来登录表单,然后我想用cookie记住系统。我开始发现这个,但我已经有一个错误,我不明白为什么会发生。 错误是这样的: 注意:未定义的索引:请记住第35行的F:\ Xampp \ htdocs \ projeto \ admin \ index.php 你能看到导致这个错误的错误吗?
<body>
<div id="login">
<img src="images/login-logo.png"/>
<div style="display:none">
<span class="ms ok">Login sucess!</span>
<span class="ms no">Error</span>
<span class="ms al">Alert</span>
<span class="ms in">Information</span>
</div>
<?php
if($_GET['remember'])
{
?>
<form name="login" action="" method="post">
<label>
<span>Email:</span>
<input type="text" class="radius" name="email" />
</label>
<label>
<span>Senha:</span>
<input type="password" class="radius" name="email" />
</label>
<input type="submit" value="Login" name="sendLogin" class="btn" />
<div class="remember">
<input type="checkbox" name="remember" value="1" /> Remember your acess data!
</div>
<a href="index.php?remember=true" class="link" title="Forgot my Password">Forgot my password</a>
</form>
<?php
}
else
{
?>
<form name="recover" action="" method="post">
<span class="ms in">Inform your email</span>
<label>
<span>Email:</span>
<input type="text" class="radius" name="email" />
</label>
<input type="submit" value="Recover" name="sendRecover" class="btn" />
<a href="index.php" class="link" title="Back">Back</a>
</form>
<?php
}
?>
</div><!-- //login -->
</body>
答案 0 :(得分:1)
您在if条件中没有使用isset()
,因此您收到以下错误
注意:未定义的索引:请记住第35行的 F:\ Xampp \ htdocs \ projeto \ admin \ index.php
如果使用isset()
,即使未定义变量,也不会收到任何错误消息
有关isset()
的更多信息,请参阅http://in1.php.net/isset
从
更改您的if条件if($_GET['remember'])
要
if( isset($_GET['remember']) )
更改了代码:
<body>
<div id="login">
<img src="images/login-logo.png"/>
<div style="display:none">
<span class="ms ok">Login sucess!</span>
<span class="ms no">Error</span>
<span class="ms al">Alert</span>
<span class="ms in">Information</span>
</div>
<?php
if($_GET['remember'])
{
?>
<form name="login" action="" method="post">
<label>
<span>Email:</span>
<input type="text" class="radius" name="email" />
</label>
<label>
<span>Senha:</span>
<input type="password" class="radius" name="email" />
</label>
<input type="submit" value="Login" name="sendLogin" class="btn" />
<div class="remember">
<input type="checkbox" name="remember" value="1" /> Remember your acess data!
</div>
<a href="index.php?remember=true" class="link" title="Forgot my Password">Forgot my password</a>
</form>
<?php
}
else
{
?>
<form name="recover" action="" method="post">
<span class="ms in">Inform your email</span>
<label>
<span>Email:</span>
<input type="text" class="radius" name="email" />
</label>
<input type="submit" value="Recover" name="sendRecover" class="btn" />
<a href="index.php" class="link" title="Back">Back</a>
</form>
<?php
}
?>
</div><!-- //login -->
</body>