Server IP : 103.53.40.154 / Your IP : 3.149.24.145 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/agratourbus.com/../thedigitaldubai.com/../shsindia.com/crm/ |
[ Home ] | [ C0mmand ] | [ Upload File ] |
---|
<?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['update_customer'])) { date_default_timezone_set('Asia/Kolkata'); $cust_id = $_POST['id']; $cp_name = $_POST['cp_name']; $cust_name = $_POST['cust_name']; $cust_number = $_POST['cust_number']; $cust_alt_number = $_POST['cust_alt_number']; $cust_email = $_POST['cust_email']; $cust_alt_email = $_POST['cust_alt_email']; $cust_address = $_POST['cust_address']; $password = $_POST['password']; $username = $_POST['username']; // $cust_status = 'Active'; $cust_bank = $_POST['cust_bank']; $cust_account = $_POST['cust_account']; $cust_ifsc = $_POST['cust_ifsc']; $cust_branch = $_POST['cust_branch']; // Handle image uploads $allowed_extensions = ['jpg', 'jpeg', 'png']; // Check and upload cust_photo if($_FILES['cust_photo']['name'] != '') { $cust_photo_extension = pathinfo($_FILES['cust_photo']['name'], PATHINFO_EXTENSION); if (in_array($cust_photo_extension, $allowed_extensions)) { $cust_photo_new_name = 'cust_photo_' . date('YmdHis') . '.' . $cust_photo_extension; move_uploaded_file($_FILES['cust_photo']['tmp_name'], 'images/customer/' . $cust_photo_new_name); } else { die("Invalid cust_photo file format. Allowed formats are jpg, jpeg, png"); } } // Construct the SQL update query $sql = "UPDATE `tbl_customer` SET `cp_name`='$cp_name', `cust_name`='$cust_name', `cust_phone`='$cust_number', `cust_alt_phone`='$cust_alt_number', `cust_email`='$cust_email', `cust_alt_email`='$cust_alt_email', `cust_address`='$cust_address', `username`='$username', `cust_bank`='$cust_bank', `cust_account`='$cust_account', `cust_branch`='$cust_branch', `cust_ifsc`='$cust_ifsc', `password`='$password'"; // Add image fields only if they are updated if(isset($cust_photo_new_name)) $sql .= ", `cust_photo`='$cust_photo_new_name'"; // Close the SQL query with WHERE clause for the specific employee ID $sql .= " WHERE `cus_id`='$cust_id'"; $result = mysqli_query($db, $sql) or die("Query unsuccessful"); if($result){ echo ("<script> window.alert('Successfully Updated'); window.location.href='manage-customer.php'; </script>"); mysqli_close($db); } else { echo "Error"; } } ?> <!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-12"> <div class="card"> <div class="card-header"> <h4 class="header-title mb-0"> Edit Customer</h4> </div> <div class="card-body"> <?php $id=$_GET['id']; $sql = "SELECT * FROM `tbl_customer` WHERE cus_id =$id"; $run = mysqli_query($db,$sql) or die("Query Not run"); $data = mysqli_fetch_assoc($run); ?> <form action="<?php $_PHP_SELF?>" method="POST" enctype="multipart/form-data"> <div id="basicwizard"> <div class=" b-0 mb-0"> <div > <div class="row"> <div class="card-header"> <h4 class="header-title">General Details</h4> </div> <div class="col-md-4 mb-3"> <label class="" for="userName">Company Name</label> <div> <input type="text" class="form-control" id="userName" name="cp_name" value="<?php echo $data['cp_name']; ?>"> </div> </div> <div class="col-md-4 mb-3"> <label class="" for="userName">Contact Person Name</label> <div> <input type="hidden" name="id" value="<?php echo $data['cus_id']?>"> <input type="text" class="form-control" id="userName" name="cust_name" value="<?php echo $data['cust_name']; ?>"> </div> </div> <div class="col-md-4 mb-3"> <label class="" for="userName">Phone Number</label> <div> <input type="text" class="form-control" id="userName" name="cust_number" value="<?php echo $data['cust_phone']; ?>"> </div> </div> <div class="col-md-4 mb-3"> <label class="" for="userName">Alt Phone</label> <div> <input type="text" class="form-control" id="userName" name="cust_alt_number" value="<?php echo $data['cust_alt_phone']; ?>"> </div> </div> <div class="col-md-4 mb-3"> <label class="" for="userName">Email</label> <div> <input type="email" class="form-control" id="userName" name="cust_email" value="<?php echo $data['cust_email']; ?>"> </div> </div> <div class="col-md-4 mb-3"> <label class="" for="userName">Alt Email</label> <div> <input type="email" class="form-control" id="userName" name="cust_alt_email" value="<?php echo $data['cust_alt_email']; ?>"> </div> </div> <div class="col-md-4 mb-3"> <label class="" for="userName">Company Logo</label> <div> <input type="file" class="form-control" id="userName" name="cust_photo" placeholder="image"> <img src="images/customer/<?php echo $data['cust_photo']; ?>" width="60px" alt="image"> </div> </div> <div class="col-md-12 mb-3"> <!--<label class="" for="userName">Address</label>--> <div> <label for="example-textarea" class="form-label">Address</label> <textarea class="form-control" id="example-textarea" rows="3" name="cust_address"><?php echo $data['cust_address']; ?></textarea> <!--<input type="text" class="form-control" id="userName" name="cust_address" placeholder="Address">--> </div> </div> <div class="card-header col-md-12"> <h4 class="header-title">Account Details</h4> </div> <div class="col-md-6 mb-3"> <label class="" for="userName">Bank Name</label> <div> <input type="text" class="form-control" id="userName" name="cust_bank" value="<?php echo $data['cust_bank']; ?>"> </div> </div> <div class="col-md-6 mb-3"> <label class="" for="userName">Account Number</label> <div> <input type="text" class="form-control" id="userName" name="cust_account" value="<?php echo $data['cust_account']; ?>"> </div> </div> <div class="col-md-6 mb-3"> <label class="" for="userName">Branch Name</label> <div> <input type="text" class="form-control" id="userName" name="cust_branch" value="<?php echo $data['cust_branch']; ?>"> </div> </div> <div class="col-md-6 mb-3"> <label class="" for="userName">IFSC Code</label> <div> <input type="text" class="form-control" id="userName" name="cust_ifsc" value="<?php echo $data['cust_ifsc']; ?>"> </div> </div> <div class="card-header"> <h4 class="header-title">Login Details</h4> </div> <div class="col-md-6 mb-3"> <label class="" for="userName">Username</label> <div> <input type="text" class="form-control" id="userName" name="username" value="<?php echo $data['username']; ?>"> </div> </div> <div class="col-md-6 mb-3"> <label class="" for="userName">Password</label> <div> <input type="text" class="form-control" id="userName" name="password" value="<?php echo $data['password']; ?>"> </div> </div> </div> <ul class="list-inline wizard mb-0"> <li class="next list-inline-item float-end"> <button class="btn btn-info" name="update_customer">Update <i class="ri-arrow-right-line ms-1"></i></button> </li> </ul> </div> </div> </div> </form> </div> </div> </div> </div> </div> </div> </div> </div> <?php include "footer.php";?> </body> </html>