%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux sh00666.bluehost.com 5.14.0-687.26.1.el9_8.x86_64 #1 SMP PREEMPT_DYNAMIC Tue Jul 14 16:32:02 EDT 2026 x86_64 User : ndkhermy ( 1200) PHP Version : 8.5.12 Disable Function : NONE Directory : /home1/ndkhermy/public_html/website_93b53270/ |
Upload File : |
<?php include('header.php');
if (!isset($_SESSION['user_id'])) {
echo "<script>window.location='login.php'</script>";
}
?>
<!-- Include Select2 CSS and JS -->
<link href="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/css/select2.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js"></script>
<style>
.select2-container .select2-selection--single{ height:40px !important; }
.select2-container--default .select2-selection--single .select2-selection__rendered{ line-height:40px !important; }
.select2-container--default .select2-selection--single .select2-selection__arrow{ height:40px !important; }
.select2-container--default .select2-selection--single{ border:none; background:#f6f5f5 !important; }
.select2.select2-container.select2-container--default.select2-container--above.select2-container--focus{ width: 100px !important; }
</style>
<section>
<div class="container">
<div class="row">
<div class="col-md-4">
<?php include('user-sidebar.php'); ?>
</div>
<div class="col-md-8">
<div class="bg-white p-5 br-20 my-5 box-shadow">
<h3 class="text-center text-danger mb-3">My profile</h3>
<form method="post" class="grey-field" enctype="multipart/form-data">
<div class="row">
<div class="col-md-6">
<label for="">Name</label>
<input type="text" name="name" value="<?=$fetch_user_id['name']?>" placeholder="Full Name" class="form-control mb-3">
</div>
<div class="col-md-6">
<label for="">Email</label>
<input type="email" name="email" value="<?=$fetch_user_id['email']?>" placeholder="Email Id" class="form-control mb-3">
</div>
<div class="col-md-6">
<label for="">Mobile Number</label>
<div class="flex-country pro">
<div>
<select class="form-control select2" name="phonecode" required style="width:90px;">
<?php $mycont = mysqli_query($conn, "SELECT * FROM `countries`");
while ($fet_cont = mysqli_fetch_array($mycont)) { ?>
<option value="<?=$fet_cont['id']?>" <?=($fet_cont['id']==$fetch_user_id['phonecode'])?'selected':''?>>+<?=$fet_cont['phonecode']?></option>
<?php } ?>
</select>
</div>
<div>
<input type="number" name="mobile_number" value="<?=$fetch_user_id['mobile_number']?>" placeholder="Mobile Number" class="form-control mb-3" style="width:230px;">
</div>
</div>
</div>
<div class="col-md-6">
<label for="">DOB</label>
<input type="date" name="DOB" value="<?=$fetch_user_id['DOB']?>" max="<?=date('Y-m-d')?>" placeholder="DOB" class="form-control mb-3">
</div>
<div class="col-md-12">
<label for="">Address</label>
<textarea name="address" rows="3" class="form-control mb-3" placeholder="Please fill Address" ><?=$fetch_user_id['address']?></textarea>
</div>
<div class="col-md-12">
<label for="">Profile Picture</label>
<input type="file" name="file" placeholder="Select Photo" class="form-control mb-3">
</div>
<div class="col-md-12">
<button type="submit" name="update" class="btn-theme w-100 nextBtn">Update</button>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</section>
<div class="alert-msg">
<?php if(isset($_SESSION['message'])): ?>
<div class="alert alert-success alert-dismissible fade show" role="alert">
<strong class="text-dark"><?php echo $_SESSION['message']; ?> <i class="feather icon-thumbs-up text-danger"></i></strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php unset($_SESSION['message']); ?>
<?php endif; ?>
<?php if(isset($_SESSION['error'])): ?>
<div class="alert alert-warning alert-dismissible fade show" role="alert">
<strong class="text-danger"><?php echo $_SESSION['error']; ?> <i class="feather icon-thumbs-up text-dark"></i></strong>
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
<?php unset($_SESSION['error']); ?>
<?php endif; ?>
</div>
<?php include('footer.php'); ?>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/select2@4.1.0-beta.1/dist/js/select2.min.js"></script>
<script>
$(document).ready(function() {
$('.select2').select2();
});
</script>
<?php
if(isset($_POST['update'])){
$name = mysqli_real_escape_string($conn,$_POST['name']);
$mobile_number = mysqli_real_escape_string($conn,$_POST['mobile_number']);
$email = mysqli_real_escape_string($conn,$_POST['email']);
$DOB = mysqli_real_escape_string($conn,$_POST['DOB']);
$phonecode = mysqli_real_escape_string($conn,$_POST['phonecode']);
$address = mysqli_real_escape_string($conn,$_POST['address']);
// Check if email already exists
$check_result = mysqli_query($conn, "SELECT * FROM `user_tbl` WHERE email='$email' AND user_id!='".$_SESSION['user_id']."'");
if (mysqli_num_rows($check_result) > 0) {
$_SESSION['error'] = "This email already exists! Try another email.";
echo "<script>window.location='registration.php';</script>";
exit;
}
$sql = mysqli_query($conn,"UPDATE `user_tbl` SET
`name`='$name',
`email`='$email',
`mobile_number`='$mobile_number',
`phonecode`='$phonecode',
`address`='$address',
`DOB`='$DOB' WHERE user_id='".$_SESSION['user_id']."'");
$file_name1=$_FILES['file']['name'];
$file_tmp1=$_FILES['file']['tmp_name'];
$file_ext1=strtolower(end(explode('.',$_FILES['file']['name'])));
if(!empty($file_name1)){
$random_number1 = rand();
$new_file_name1 = $random_number1.'.'.$file_ext1;
$file_path1="images/Upload/user/".$new_file_name1;
move_uploaded_file($file_tmp1,$file_path1);
$dlt=mysqli_fetch_array(mysqli_query($conn,"SELECT * FROM `user_tbl` WHERE user_id='".$_SESSION['user_id']."'"));
$dlt_path="images/Upload/user/".$dlt['image1'];
unlink($dlt_path);
mysqli_query($conn,"UPDATE `user_tbl` SET `image1`='$new_file_name1' WHERE user_id='".$_SESSION['user_id']."'");
}
if($sql){
$_SESSION['message'] = "Successfully Update Your Profile!";
echo "<script>window.location='user-profile.php';</script>";
exit;
} else {
$_SESSION['error'] = "Something went wrong! Sorry.";
echo "<script>window.location='registration.php';</script>";
exit;
}
}
?>