简体   繁体   English

PHP用户登录,需要数据库身份验证和重定向帮助

[英]PHP user log in, database authentication and redirect help needed

I'm a beginner developer stuck in a tough situation needing to deliver this project I haven't been able to grasp completely. 我是一个初学者开发者陷入困境,需要提供这个我完全无法掌握的项目。

There is a page with a login button. 有一个带登录按钮的页面。 When you press that button, it takes you to wp admin instead of verifying your given permission level in wp mysql database, and based on that transferring you to the appropriate web site. 当您按下该按钮时,它会将您带到wp admin,而不是在wp mysql数据库中验证您的给定权限级别,并基于此将您转移到相应的网站。 I figured out how to connect to database and verify user but I'm not sure how put in multiple parameters because there are 5 sections of privileges given to users. 我想出了如何连接到数据库并验证用户,但我不确定如何放入多个参数,因为有5个部分的权限给用户。 Based on their privileges they get sent to another part of the website. 根据他们的特权,他们会被发送到网站的另一部分。 I'm using the header php function to redirect but I am unsure if I can include it in the same file and how do I tie this file to existing wp login page? 我正在使用标题php函数重定向但我不确定我是否可以将它包含在同一个文件中,如何将此文件绑定到现有的wp登录页面? Please help! 请帮忙!

<?php

  error_reporting(0);
  session_start();
  class logmein {
  var $hostname_logon = 'localhost';     
  var $database_logon = '';      
  var $username_logon = '';      
  var $password_logon = '';      

  var $user_table = 'logon';         
  var $user_column = 'useremail';    
  var $pass_column = 'password';     
  var $user_level = 'userlevel';     
  var $encrypt = false;

  function dbconnect(){
    $connections = mysql_connect($this->hostname_logon,    $this->username_logon, $this->password_logon) or die ('Unabale to connect to   the database');
    mysql_select_db($this->database_logon) or die ('Unable to select   database!');
    return;
  }

  function login($table, $username, $password){

    $this->dbconnect();

    if($this->user_table == ""){
      $this->user_table = $table;
    }
    if($this->encrypt == true){
      $password = md5($password);
    }

    header("Location: https://example.com/members/index.php"); 

For your quick setup here us example multi-user-role-based-login-in-php-with-mysql 为了您的快速设置,我们举例说明基于多用户角色的登录在php-with-mysql中

This site have mention everything about your needs. 这个网站提到了有关您需求的一切。 Use "roleid" column in user table so that you identify that user type is what. 在用户表中使用“roleid”列,以便您确定该用户类型是什么。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM