<?php

require_once("config/configDB.php"); 

$username = stripslashes($_POST['username']);
$pwd      = $username."@123";
$sql      = "INSERT INTO user_login (username,password,loginstatus,flag,user_permisson) VALUES ('$username','$pwd','2' ,'1','USER')";
mysqli_query($conn,$sql);

$userID = mysqli_insert_id($conn);

$sql_product = "SELECT * FROM user_permission_master where activestatus=1";
$result = $conn->query($sql_product);

if ($result->num_rows > 0) {
    while($row = $result->fetch_assoc()) {

        
        $filenames  = $row['filenames'];
        $dataadd    = $row['dataadd'];
        $dataedit   = $row['dataedit'];
        $datadelete = $row['datadelete'];
        $datashow   = $row['datashow'];
        $dataprint  = $row['dataprint'];
        $dataexcelformat    = $row['dataexcelformat'];        
        $activestatus       = $row['activestatus'];

        $sql_mapping  = "INSERT INTO user_permission (userID, filenames, dataadd, dataedit, datadelete, datashow, dataprint, dataexcelformat, activestatus) VALUES ('$userID', '$filenames', '$dataadd', '$dataedit', '$datadelete', '$datashow', '$dataprint', '$dataexcelformat', '$activestatus')";
        
        mysqli_query($conn,$sql_mapping);        
    }
} 
$conn->close();

header("Location:usersMasterDashboard.php");

?>