Suppose you have 3 sites, A, B, C where A is the main

- STEP 1
    Create a new table [] in website database

- STEP 2
    Create a folder name api in root of site A

- STEP 3
    Create get.php and past the code below

    <?php
        $id = $_GET['a'];
        include ('../configuration.php');
        $MJConfig = new JConfig();
        $username = $MJConfig->user;
        $password = $MJConfig->password;
        $host = $MJConfig->host;
        $db = $MJConfig->db;
        $connect = mysqli_connect($host, $username, $password, $db);
        $sql = "SELECT * FROM custom_login_api WHERE id='$id'";
        $result = mysqli_query($connect, $sql);
        if(mysqli_num_rows($result) > 0) {
            while ($row = mysqli_fetch_array($result)) {
                print_r(json_encode($row));
            }
        }
        $connect->close();
    ?>  

- STEP 4
    Create update.php and past the code below
        
    <?php
        $arr = json_decode($_POST['arr'],true);
        $id = $arr[0];
        $name = $arr[1];
        $pass = $arr[2];
        include ('../configuration.php');
        $MJConfig = new JConfig();
        $username = $MJConfig->user;
        $password = $MJConfig->password;
        $host = $MJConfig->host;
        $db = $MJConfig->db;
        $connect = mysqli_connect($host, $username, $password, $db);
        $sql = "INSERT INTO custom_login_api(`id`,`one`,`two`) values ('$id','$name','$pass')";
        //            echo $sql;
        if ($connect->query($sql) === TRUE) {
        //    echo "<script>UIkit.notification({message: 'New author created successfully'})</script>";
            // header("Location: backoffice.php"); var decrypted = CryptoJS.AES.decrypt(encrypted, "Secret Passphrase");
            echo $id;
        } else {
            echo "Error: " . $sql . "<br>" . $connect->error;
        }
        $connect->close();
    ?>

- STEP 5
    Add class login-button in login form submit button

- STEP 6
    Copy and paste the code below in A admin login.php page & replace link to site B and C below & replace your custom encryption key

        <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
        <script src="https://cdnjs.cloudflare.com/ajax/libs/crypto-js/3.1.2/rollups/aes.js"
            integrity="sha256-/H4YS+7aYb9kJ5OKhFYPUjSJdrtV6AeyJOtTkw6X72o=" crossorigin="anonymous"></script>
        <script>
            $('.login-button').click(function () {
                var arr = ['<?=uniqid()?>'];
                $('.input-medium').each(function () {
                    arr.push(CryptoJS.AES.encrypt($(this).val(), '123456789').toString());
                });
                arr = JSON.stringify(arr);
                $.ajax({
                    url: "/cim-backoffice-01/api/update.php",
                    method: "POST",
                    data: {
                        arr: arr
                    },
                    success: function (data) {
                        // alert(data);
                        window.open('https://cimfinance.mu/administrator?a=' + data, '_blank');
                        window.open('https://about.cimfinance.mu/administrator?a=' + data, '_blank');
                    }
                });
            });
        </script>


- STEP 7
    Copy and paste the code below in site B and C in /administrator/template/.../login.php file & replace encryption key and respective link

        <script>                                                                                                                                                                                                           
        $( document ).ready(function() {
                $.getJSON('https://bko.cimfinance.mu/api/get.php?a=<?=$_GET['a']?>', function(data){
                        $('#mod-login-username').val(CryptoJS.AES.decrypt(data.one, "123456789").toString(CryptoJS.enc.Utf8));
                        $('#mod-login-password').val(CryptoJS.AES.decrypt(data.two, "123456789").toString(CryptoJS.enc.Utf8));
                        $('.login-button').trigger('click');
                });                                                                                                                                                                                                        });                                                                                                                                                                                                                
        </script>   

