MMCT TEAM
Server IP : 103.53.40.154  /  Your IP : 18.222.92.56
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 (0750) :  /home2/ppcad7no/deergham.com/

[  Home  ][  C0mmand  ][  Upload File  ]

Current File : /home2/ppcad7no/deergham.com/customer-profile.php
<?php 

    session_start();

    include_once('admin/config.php');
    
    if(!isset($_SESSION["user"]) OR $_SESSION["user"] == "" ){
        
        header('location:login.php');
    }
    
    if($_SERVER["REQUEST_METHOD"] === 'POST'){
        if(isset($_POST['submit'])){
        $c_id = $_POST['id'];
        $b_image = $_FILES['image'];
        move_uploaded_file($_FILES['image']['tmp_name'],'imgs/Customer-image/'.$_FILES['image']['name']);
        $upload_image = $_FILES['image']['name'];
        $full_name = $_POST["full_name"];
        $address = $_POST["address"];
        $city = $_POST["city"];
        $state = $_POST["state"];
        $postal_c = $_POST["postal_c"];
        $about_us = $_POST["about_us"];
        
        if($_FILES['image']['name'] == ''){
            $sql_c = "UPDATE `tbl_customer` SET `cust_name` = '$full_name', `address` = '$address', `city` = '$city',
                `state` = '$state', `postal_c` = '$postal_c', `about_us` = '$about_us' WHERE `cus_id` = '$c_id'";
            $run_c = mysqli_query($db,$sql_c);
            
            $run_c = mysqli_query($db,$sql_c);
            if($run_c){
            
            echo "<script>
                    window.alert('Profile Upadted Successfully.');
                    window.location.href = 'customer-profile.php';
                    </script>";
            }else{
                echo "<script>
                    window.alert('Error. Profile Not Upadted.');
                    window.location.href = 'customer-profile.php';
                    </script>";
                    mysqli_close($db);
            }
        
        }else{
            $sql_c1 = "UPDATE `tbl_customer` SET `cust_photo` = '$upload_image', `cust_name` = '$full_name', `address` = '$address',
            `city` = '$city', `state` = '$state', `postal_c` = '$postal_c', `about_us` = '$about_us' WHERE `cus_id` = '$c_id'";
            $run_c1 = mysqli_query($db,$sql_c1);
            
            if($run_c1){
                
                echo "<script>
                        window.alert('Profile Upadted Successfully.');
                        window.location.href = 'customer-profile.php';
                        </script>";
            }else{
                    echo "<script>
                        window.alert('Error. Profile Not Upadted.');
                        window.location.href = 'customer-profile.php';
                        </script>";
                        mysqli_close($db);
            }
        }  
        }
    }
?>


<!DOCTYPE html>
<html lang=en>

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <?php include "top-links.php" ?>
    <title><?= $datahome['site_pages_meta_title'] ?></title>
    <meta name="description" content="<?= $datahome['site_pages_meta_description'] ?>">
    <link rel="stylesheet" href="<?php echo $wspath?>css/customer.min.css">
    <style>
        .error{
            color:red;
        }
    </style>
</head>

<body>
    <?php include "header.php" ?>
   
    <main>
    <header class="page" style="padding-top:;">
        <div class="page_main container-fluid">
            <div class="container">
                <h1 class="page_header">My Profile</h1>
            </div>
        </div>
        <div class="container">
            <ul class="page_breadcrumbs d-flex flex-wrap">
                <li class="page_breadcrumbs-item"><a class="link" href="<?php echo $wspath?>">Home</a></li>
                <li class="page_breadcrumbs-item current"><span>User Profile</span></li>
            </ul>
        </div>
    </header>
        <div class="container ">
            <div class="row">
                <div class="col order-lg-12">
                    <div class="card bg-secondary shadow">
                        <div class="card-header bg-white border-0">
                            <div class="row align-items-center">
                                <div class="col-8">
                                    <h3 class="mb-0">My account</h3>
                                </div>
                                <div class="col-4">
                                <a href="cust-logout.php" class="btn" ><strong>Log Out</strong></a>
                                </div>
                            </div>
                        </div>
                            <div class="card-body">
                            <form action="<?php $_PHP_SELF?>" method="POST" enctype="multipart/form-data">
                                <h6 class="heading-small text-muted mb-4">User information</h6>
                                <div class="pl-lg-4">
                                    <div class="row">
                                        <?php
                                        $email = $_SESSION["user"]["cust_email"];
                                        $sql_c = "SELECT * FROM tbl_customer WHERE `cust_email` = '$email'";
                                        $run_c = mysqli_query($db,$sql_c);
                                        $data_c = mysqli_fetch_assoc($run_c);
                                        $id = $data_c["cus_id"];
                                        $f_name = $data_c["cust_name"];
                                        $phone = $data_c["cust_phone"];
                                        $address = $data_c["address"];
                                        $city = $data_c["city"];
                                        $state =  $data_c["state"];
                                        $postal_c =  $data_c["postal_c"];
                                        $about =  $data_c["about_us"];
                                        
                                        ?>
                                        <div class="col-lg-12">
                                            <div class="form-group focused">
                                                <input type="hidden" id="input-username" name="id" value = "<?= $id ?>" class="form-control form-control-alternative">
                                            </div>
                                        </div>
                                        <div class="col-lg-6">
                                            <div class="form-group focused" style="padding: 25px 50px;" >
                                                <img  src="<?= $image = !empty($data_c["cust_photo"]) ? $wspath.'imgs/Customer-image/'.$data_c["cust_photo"] : 'imgs/Customer-image/default-img.jpeg'; ?>" alt="" >
                                            </div>
                                        </div>
                                        
                                        <div class="col-lg-6">
                                            <div class="form-group focused">
                                                <label class="form-control-label" for="input-username">Profile Image</label>
                                                <input type="file" id="input-username" name="image" class="form-control">
                                            </div>
                                        </div>
                                        <div class="col-lg-4">
                                            <div class="form-group focused">
                                                <label class="form-control-label" for="input-username">Full Name</label>
                                                <input type="text" id="input-username" class="form-control form-control-alternative"
                                                    placeholder="full name" value="<?= $f_name ?>" name="full_name">
                                            </div>
                                        </div>
                                        <div class="col-lg-4">
                                            <div class="form-group">
                                                <label class="form-control-label" for="input-email">Email address</label>
                                                <input type="email" id="input-email" class="form-control form-control-alternative"
                                                    placeholder="jesse@example.com"  readonly value="<?= $email ?>">
                                            </div>
                                        </div>
                                        <div class="col-lg-4">
                                            <div class="form-group focused">
                                                <label class="form-control-label" for="input-username">Phone No.</label>
                                                <input type="text" id="input-username" class="form-control form-control-alternative"
                                                    readonly value="<?= $phone ?>">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <hr class="my-4">
                                <!-- Address -->
                                <h6 class="heading-small text-muted mb-4">Contact information</h6>
                                <div class="pl-lg-4">
                                    <div class="row">
                                        <div class="col-md-12">
                                            <div class="form-group focused">
                                                <label class="form-control-label" for="input-address">Address</label>
                                                <input id="input-address" class="form-control form-control-alternative"
                                                    placeholder="Home Address" value="<?= $address ?>"
                                                    type="text" name="address">
                                            </div>
                                        </div>
                                    </div>
                                    <div class="row">
                                        <div class="col-lg-4">
                                            <div class="form-group focused">
                                                <label class="form-control-label" for="input-city">City</label>
                                                <input type="text" id="input-city" class="form-control form-control-alternative"
                                                    placeholder="City" value="<?= $city ?>" name="city">
                                            </div>
                                        </div>
                                        <div class="col-lg-4">
                                            <div class="form-group focused">
                                                <label class="form-control-label" for="input-country">Country</label>
                                                <input type="text" id="input-country" class="form-control form-control-alternative"
                                                    placeholder="Country" value="<?= $state ?>" name="state">
                                            </div>
                                        </div>
                                        <div class="col-lg-4">
                                            <div class="form-group">
                                                <label class="form-control-label" for="input-country">Postal code</label>
                                                <input type="number" id="input-postal-code" name="postal_c"
                                                    class="form-control form-control-alternative" placeholder="Postal code" value = "<?= $postal_c ?>">
                                            </div>
                                        </div>
                                    </div>
                                </div>
                                <hr class="my-4">
                                <!-- Description -->
                                <h6 class="heading-small text-muted mb-4">About me</h6>
                                <div class="pl-lg-4">
                                    <div class="form-group focused">
                                        <label>About Me</label>
                                        <textarea rows="4" class="form-control form-control-alternative" name="about_us"><?= $about ?></textarea>
                                    </div>
                                </div>
                                <div class="col-12 text-center">
                                    <button type="submit" class="btn" name="submit" >Save Changes</button>
                                </div>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </main>
    
    <?php include "footer.php" ?>
</body>

</html>

MMCT - 2023