我如何在PHP验证登录表单后调用网页


How can i call a webpage after verifying the login form in PHP?

我创建了一个登录页面,其中通过发送消息成功地完成了验证过程。但是我想通过点击有效用户的登录按钮来打开网页。

 if ($password != $pass)'''' .....comparing the password
                {
               echo"Please Register your details";''''...error message 
                } 
                else{
                header("Location=https://www.google.com/www.funworld.com/");''valid user can enter into this website
                }

Location标头格式不正确。使用冒号,而不是等号:

header("Location: https://www.google.com/www.funworld.com/");

注意事项:

  1. 这个Google URL不存在,所以如果这是你实际使用的,那么你没有重定向用户到有用的地方。
  2. 我建议使用比"Please Register your details"更具体的错误。如果用户已经注册,但没有正确登录,这可能会令人困惑。
  3. if ($password != $pass)告诉我你没有以明文形式存储用户密码,并且正确地散列了它们。我知道我技术上没有理由相信这一点,但看起来你确实可能在使用纯文本密码。为了其他读到这篇文章的人…没有以明文形式存储用户密码的理由。
if ($password != $pass)'''' .....comparing the password
            {
           echo"Please Register your details";''''...error message 
            } 
            else{
            header("Location:https://www.google.com/www.funworld.com/");''valid user can enter into this website
            }
}

尝试一下(注意'='在header函数中被更改为冒号)

/*if user is valid(after fetching data from database) */
header("location:pagename.php ");
 else
 echo"incorrect username/password";