How To Self Mainadmin Register And Login Bug Fix?

How To Self Mainadmin Register And Login Bug Fix?

Posted on : 29 Sep, 2023    |    Last Update - 1 year ago   

Follow The Steps Below

  1. Login your Hosting or Server and find this path public_html/portallogin/ folder.
  2. Open listofusers.php file and update this code ðŸ‘‡
   <?php
    if(isset($_POST['action'])){

    if($userdata['usertype']=="mainadmin"){
    $sql = $conn->prepare("DELETE FROM loginusers WHERE id=?");
    if($sql->execute([$_POST['usrid']])){
    echo '<div class="alert alert-success alert-dismissible fade show" role="alert">
      <strong>Delete!</strong> Users Successfully!
    </div>';    
    }else{
    echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
      <strong>Error!</strong> Data Not Insert!
    </div>';        
    }
    }else{
    echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
      <strong>Error!</strong> Permission Denied!
    </div>';        
    }

        
    }
    ?>   

    <?php
    if(isset($_POST['resetpass']) && !empty($_POST['usrid'])){
    $stmt = $conn->prepare("select * from loginusers WHERE id = ?");
    $stmt->execute([$_POST['usrid']]);
    $urow=$stmt->fetch();

    if($urow['id']>0){
        

    if($userdata['id']==$urow['id'] || $userdata['id']==$_POST['usrid']){
    exit("Get Out");
    }


    if(in_array($urow['usertype'],['supdistributor','distributor','retailer']) || $userdata['usertype']=="mainadmin"){
        
    $hash = password_hash($urow['username'],PASSWORD_DEFAULT);    
    $sql = $conn->prepare("UPDATE loginusers SET password=?  WHERE id=?");
    if($sql->execute([$hash,$urow['id']])){
    echo '<div class="alert alert-success alert-dismissible fade show" role="alert">
      <strong>Reset!</strong> Password Successfully!
    </div>';    
    }else{
    echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
      <strong>Error!</strong> Data Not Insert!
    </div>';        
    }


    }else{
    echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
      <strong>Error!</strong> Not Access!
    </div>';    
    }

    }else{
    echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
      <strong>Error!</strong> invalid user!
    </div>';        
    }



        
    }
    ?> 

    <?php
    if(isset($_POST['usr_update']) && !empty($_POST['status'])  && !empty($_POST['usertype'])  ){
    $stmt = $conn->prepare("select * from loginusers WHERE id = ?");
    $stmt->execute([$_POST['usrid']]);
    $urow=$stmt->fetch();

    if($userdata['id']==$urow['id'] || $userdata['id']==$_POST['usrid']){
    exit("Get Out");
    }

    if(in_array($_POST['usertype'],['mainadmin','wluser'])){
    $_POST['usertype'] = "retailer";
    }

    if(in_array($_POST['usertype'],['supdistributor','distributor','retailer'])){
    $hash = password_hash($urow['username'],PASSWORD_DEFAULT);    
    $sql = $conn->prepare("UPDATE loginusers SET status=?, usertype=?  WHERE id=?");
    if($sql->execute([$_POST['status'],$_POST['usertype'],$_POST['usrid']])){
    echo '<div class="alert alert-success alert-dismissible fade show" role="alert">
      <strong>Users!</strong> Update Successfully!
    </div>';    
    }else{
    echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
      <strong>Error!</strong> Data Not Insert!
    </div>';        
    }

    }else{
    echo '<div class="alert alert-danger alert-dismissible fade show" role="alert">
      <strong>Error!</strong> Not Access!
    </div>';    
    }
        
    }
?>

       3. Open register.php file and update this code as per screenshot 👇.

$_POST['usertype'] = "retailer";

           

 

       4. Open database folder header.php file and add this code as per screenshot 👇.

if($userdata['usertype']=="mainadmin"){
if($userdata['id']>1){
    session_destroy();
    header('Location: logout');
    exit();    
}  
}

           

 

       5. Open phpMyAdmin and select your database and run this query as per screenshot 👇.

SELECT * FROM `loginusers` WHERE `usertype` = 'mainadmin'

If you see any unknown main admin user delete it immediately.

           

 

Watch this video for more details 👇.

https://youtu.be/Mv_aj_zO7RU?si=nOjY7YL1J4-BY93h

  • Other Categories
  •   Pan Card

    Still No Luck ? We can help you

    Create a ticket, we’ll get back to you as soon as possible.

    Submit a Ticket