MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 3.142.212.153
Web Server : Apache
System : Linux md-in-35.webhostbox.net 4.19.286-203.ELK.el7.x86_64 #1 SMP Wed Jun 14 04:33:55 CDT 2023 x86_64
User : ppcad7no ( 715)
PHP Version : 8.2.25
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : ON
Directory (0755) :  /home2/ppcad7no/asksolution.in/../drckjon.in/../shsindia.com/crm/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/ppcad7no/asksolution.in/../drckjon.in/../shsindia.com/crm/user-profile.php
<?php
include_once('include/config.php');
if (!isLoggedIn()) {
    $_SESSION['msg'] = "You must log in first";
    header('location: login.php');
}
if (!isAdmin()) {
    $_SESSION['msg'] = "You are not Admin";
    header('location: login.php');
}
if(isset($_POST['submit'])) {

    $profile = $_FILES['profile']['name'];
    $name = $_POST['name'];
    $email = $_POST['email'];
    $phone = $_POST['phone'];
    
    $tech_name = $_POST['tech_name'];
    $tech_email = $_POST['tech_email'];
    $tech_phone = $_POST['tech_phone'];
    
    $bank_name = $_POST['bank_name'];
    $bank_number = $_POST['bank_number'];
    $bank_ifsc = $_POST['bank_ifsc'];
    $bank_branch = $_POST['bank_branch'];
    
    $gst = $_POST['gst'];
    $address = $_POST['address'];
    $username = $_POST['username'];
    $password = $_POST['password'];
    $about_u = $_POST['about_u'];

    // Handle image uploads
    $allowed_extensions = ['jpg', 'jpeg', 'png'];

    // Check and upload profile image
    if($profile != '') {
        $profile_extension = pathinfo($profile, PATHINFO_EXTENSION);
        if (in_array($profile_extension, $allowed_extensions)) {
            $profile_new_name = 'profile_' . date('YmdHis') . '.' . $profile_extension;
            move_uploaded_file($_FILES['profile']['tmp_name'], 'images/' . $profile_new_name);
        } else {
            die("Invalid profile image file format. Allowed formats are jpg, jpeg, png");
        }
    }

    // Check if an existing profile image needs to be removed
    $sql_select = "SELECT profile FROM login_tbl WHERE id='2'";
    $result_select = mysqli_query($db, $sql_select);
    $row = mysqli_fetch_assoc($result_select);
    $existing_profile = $row['profile'];

    if($profile != '' && isset($existing_profile)) {
        // Delete the existing profile image
        unlink('images/' . $existing_profile);
    }

    // Construct the SQL update query
    $sql = "UPDATE `login_tbl` SET 
            `name`='$name', 
            `email`='$email', 
            `phone`='$phone', 
            `gst`='$gst', 
            `address`='$address', 
            `username`='$username', 
            `password`='$password',
            `tech_name`='$tech_name',
            `tech_phone`='$tech_phone',
            `tech_email`='$tech_email',
            `bank_name`='$bank_name',
            `bank_number`='$bank_number',
            `bank_branch`='$bank_branch',
            `bank_ifsc`='$bank_ifsc',
            `about_u`='$about_u'";

    // Add profile image field only if it is updated
    if(isset($profile_new_name))
        $sql .= ", `profile`='$profile_new_name'";

    // Close the SQL query with Company WHERE clause
    $sql .= " WHERE id='2'";

    $result = mysqli_query($db, $sql) or die("Query unsuccessful");

    if($result){
        echo ("<script>
        window.alert('Successfully Updated');
        window.location.href='manage-company.php';
        </script>");
        mysqli_close($db);
    } else {
        echo "Error";
    }
}
?>

<?php
    $user=$_SESSION['user']['id'];
    $sqlprof = "SELECT * FROM login_tbl WHERE id='$user'";
    $runprof = mysqli_query($db,$sqlprof) or die("Query Not run");
    $dataprof = mysqli_fetch_assoc($runprof);
?>
<!DOCTYPE html>
<html lang="en">
    
<head>
    <?php include "top-links.php";?>
</head>

    <body>
        <!-- Begin page -->
        <div class="wrapper">

            <?php include "header.php";?>

            <?php include "sidebar.php";?>
            
              <div class="content-page">
            <div class="content">

                <!-- Start Content-->
                <div class="container-fluid">

                    <div class="row">
                        <div class="col-sm-12">
                            <div class="card p-0">
                                <div class="card-body p-0">
                                    <div class="profile-content">
                                        <ul class="nav nav-underline nav-justified gap-0 pt-2">
                                            <li class="nav-item"><a class="nav-link active" data-bs-toggle="tab" data-bs-target="#aboutme" type="button" role="tab" aria-controls="home" aria-selected="true" href="#aboutme">My Profile</a>
                                            <!--</li><li class="nav-item"><a class="nav-link" data-bs-toggle="tab" data-bs-target="#edit-profile" type="button" role="tab" aria-controls="home" aria-selected="true" href="#edit-profile">Settings</a></li>-->
                                            <!--<li class="nav-item"><a class="nav-link" data-bs-toggle="tab" data-bs-target="#projects" type="button" role="tab" aria-controls="home" aria-selected="true" href="#projects">Projects</a></li>-->
                                        </ul>

                                        <div class="tab-content m-0 p-4">
                                            <div class="tab-pane active" id="aboutme" role="tabpanel"
                                                aria-labelledby="home-tab" tabindex="0">
                                                <div class="profile-desk">
                                                    <h5 class="text-uppercase fs-17 text-dark"><?php echo $dataprof['name'];?></h5>
                                                    <div class="designation mb-4"><?php echo $dataprof['user_type'];?></div>

                                                    <h5 class="mt-4 fs-17 text-dark">Contact Information</h5>
                                                    <table class="table table-condensed mb-0 border-top">
                                                        <tbody>
                                                            <tr>
                                                                <th scope="row">Name</th>
                                                                <td>
                                                                    <?php echo $dataprof['name'];?>
                                                                </td>
                                                            </tr>
                                                            <tr>
                                                                <th scope="row">Email</th>
                                                                <td>
                                                                    <?php echo $dataprof['email'];?>
                                                                </td>
                                                            </tr>

                                                            <tr>
                                                                <th scope="row">Phone</th>
                                                                <td class="ng-binding"><?php echo $dataprof['phone'];?></td>
                                                            </tr>
                                                            <tr>
                                                                <th scope="row">Address</th>
                                                                <td>
                                                                    <?php echo $dataprof['address'];?>
                                                                </td>
                                                            </tr>
                                                            
                                                            <tr>
                                                                <!--<th scope="row">Edit Company </th>-->
                                                                <th>
                                                                    <a href="edit-profile.php"><button class="btn btn-primary" type="submit" name="submit"><i class="ri-save-line me-1 fs-16 lh-1"></i> Edit Profile</button></a>
                                                                </th>
                                                            </tr>
                                                        </tbody>
                                                    </table>
                                                    
                                                </div> <!-- end profile-desk -->
                                                
                                            </div> <!-- about-me -->
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- end page title -->

                </div>
                <!-- end row -->

            </div>
            <!-- container -->

        </div>
        </div>
        <script>
            function togglePasswordVisibility() {
                var passwordField = document.getElementById('password');
                var passwordToggle = document.getElementById('password-toggle');
                if (passwordField.type === 'password') {
                    passwordField.type = 'text';
                    passwordToggle.className = 'ri-eye-line fs-22';
                } else {
                    passwordField.type = 'password';
                    passwordToggle.className = 'ri-eye-off-line fs-22';
                }
            }
        </script>
        <?php include "footer.php";?>
        
    </body>

</html> 

MMCT - 2023