Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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. 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. 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? 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"); 
like image 345
pertini Avatar asked Mar 26 '26 07:03

pertini


1 Answers

For your quick setup here us example multi-user-role-based-login-in-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.

like image 79
Chintan7027 Avatar answered Mar 28 '26 21:03

Chintan7027



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!