Notice: Trying to get property of non求大神指导下
程序员文章站
2024-01-05 19:51:34
...
一个简单的登录判断下post过来的用户名username和密码pwd否相同
$user = User::getByname(username);//查询到的时候为空会报错
if($user->username == $_POST['username'] && $user->pwd== $_POST['pwd'])
但
if(isset($user->username))//这样没事
但我想实现上面那个登录判断下post过来的用户名username和密码pwd否相同的逻辑
请问该怎样解决,不要说@了
$user = User::getByname(username);//查询到的时候为空会报错
if($user->username == $_POST['username'] && $user->pwd== $_POST['pwd'])
但
if(isset($user->username))//这样没事
但我想实现上面那个登录判断下post过来的用户名username和密码pwd否相同的逻辑
请问该怎样解决,不要说@了
回复讨论(解决方案)
if($_POST) {
$user = User::getByname($_POST['username']);
if($user->username == $_POST['username'] && $user->pwd== $_POST['pwd'])
....
先判断有没有点击登录
if(isset($_POST['submit'])){
if($user->username == $_POST['username'] && $user->pwd== $_POST['pwd']){
}
}
这样就不会出用户没值报错了
推荐阅读
-
Notice: Trying to get property of non求大神指导下
-
Notice: Trying to get property of non-object problem(PHP)解_PHP
-
Notice: Trying to get property of non-object problem(PHP)解决办法
-
Notice: Trying to get property of non求大神指导下
-
Notice: Trying to get property of non-object problem(PHP)解_PHP
-
Notice: Trying to get property of non-object problem(PHP)解决办法
-
Notice: Trying to get property of non-object problem(PHP)解决办_PHP教程
-
Notice: Trying to get property of non-object problem(PHP)解决办法_php基础
-
Notice: Trying to get property of non-object problem(PHP)解决办法_php基础
-
system.getproperty Notice: Trying to get property of non-object problemPHP解决办法