<?php
include('header.php');
if (isset($_POST['s_profile']) && $_POST['s_profile'] == "ahkweb" && $_POST['phone'] != "ADMIN" && $_POST['email'] != "ADMIN") {
	$name = mysqli_real_escape_string($conn, $_POST['name']);
	$email = mysqli_real_escape_string($conn, $_POST['email']);
	$phone = mysqli_real_escape_string($conn, $_POST['phone']);

	$sres = mysqli_query($conn, "UPDATE usertable SET name='$name', emailid='$email', phone='$phone' WHERE emailid='$mail' ");
	if ($sres) {
?>
		<script>
			$(function() {
				Swal.fire(
					'Success!',
					'Your Profile data Updated Successfully',
					'success'
				)
			});
		</script>
	<?php
	} else {
	?>
		<script>
			$(function() {
				Swal.fire(
					'Opps!',
					'Internal Server Error, Please Try Again Later',
					'error'
				)
			});
		</script>
		<?php
	}
}

if (isset($_POST['s_password']) && $_POST['s_password'] == "ahkwebsolutions") {
	$password = mysqli_real_escape_string($conn, $_POST['password']);
	$cpassword = mysqli_real_escape_string($conn, $_POST['cpassword']);
	if ($password == $cpassword) {
		$fpassword = password_hash($password, PASSWORD_DEFAULT);
		$pres = mysqli_query($conn, "UPDATE usertable SET password='$fpassword' WHERE emailid='$mail' ");

		if ($pres) {
		?>
			<script>
				$(function() {
					Swal.fire(
						'Success!',
						'Your Password Updated Successfully',
						'success'
					)
				});
			</script>
		<?php
		} else {
		?>
			<script>
				$(function() {
					Swal.fire(
						'Opps!',
						'Internal Server Error, Please Try Again Later',
						'error'
					)
				});
			</script>
		<?php
		}
	} else {
		?>
		<script>
			$(function() {
				Swal.fire(
					'Opps!',
					'Confirm Password Does not Match',
					'error'
				)
			});
		</script>
<?php
	}
}

?>
 <style>
/* ===================== PAGE BACKGROUND ===================== */
body{
    background:linear-gradient(135deg,#0f2027,#203a43,#2c5364);
    font-family:"Poppins",sans-serif;
    min-height:100vh;
}

/* ===================== PAYMENT CARD ===================== */
.payment-form{
    max-width:1400px;
    margin:40px auto;
    background:linear-gradient(135deg,#ffffff,#f4f7ff);
    padding:25px 30px;
    border-radius:18px;
    box-shadow:0 20px 50px rgba(0,0,0,.35);
    position:relative;
}

/* TOP BORDER GLOW */
.payment-form::before{
    content:'';
    position:absolute;
    top:0;
    left:0;
    right:0;
    height:6px;
    background:linear-gradient(135deg,#11998e,#38ef7d);
    border-radius:18px 18px 0 0;
}

/* ===================== HEADING ===================== */
.payment-form h1{
    text-align:center;
    font-weight:800;
    color:#1e3c72;
    margin-bottom:25px;
    letter-spacing:1px;
}

/* ===================== LABEL ===================== */
.payment-form label{
    font-weight:600;
    color:#2c3e50;
    margin-bottom:6px;
}

/* ===================== INPUTS (ALL TYPES) ===================== */
.payment-form input[type="text"],
.payment-form input[type="password"],
.payment-form input[type="email"],
.payment-form input[type="name"],
.payment-form input[type="number"],
.payment-form select,
.payment-form textarea{
    width:100%;
    padding:14px 16px;
    margin-bottom:15px;
    border-radius:30px;
    border:1px solid #d0d7ff;
    font-size:15px;
    transition:all .3s ease;
    box-shadow:inset 0 2px 6px rgba(0,0,0,.08);
    background:#fff;
}

/* PLACEHOLDER */
.payment-form input::placeholder,
.payment-form textarea::placeholder{
    color:#999;
    font-weight:500;
}

/* ===================== FOCUS EFFECT ===================== */
.payment-form input[type="text"]:focus,
.payment-form input[type="password"]:focus,
.payment-form input[type="email"]:focus,
.payment-form input[type="name"]:focus,
.payment-form input[type="number"]:focus,
.payment-form select:focus,
.payment-form textarea:focus{
    outline:none;
    border-color:#396afc;
    box-shadow:0 0 0 3px rgba(57,106,252,.25);
}

/* ===================== BUTTON ===================== */
.payment-form button,
.payment-form input[type="submit"]{
    width:100%;
    padding:14px;
    margin-top:10px;
    border-radius:30px;
    font-weight:700;
    font-size:16px;
    border:none;
    cursor:pointer;
    background:linear-gradient(135deg,#11998e,#38ef7d);
    color:#fff;
    box-shadow:0 6px 18px rgba(0,0,0,.35);
    transition:all .25s ease;
}

/* BUTTON HOVER */
.payment-form button:hover,
.payment-form input[type="submit"]:hover{
    transform:translateY(-2px);
    box-shadow:0 10px 28px rgba(0,0,0,.45);
}

/* ===================== CARD BODY / FOOTER ===================== */
.payment-form .card-body{
    padding:0;
}

.payment-form .card-footer{
    background:none;
    border:none;
    padding-top:10px;
}

/* ===================== INFO & ALERT ===================== */
.bg-info{
    background:linear-gradient(135deg,#396afc,#2948ff)!important;
    color:#fff;
    font-weight:700;
    padding:10px;
    border-radius:10px 0 0 10px;
}

.bg-danger{
    background:linear-gradient(135deg,#ff416c,#ff4b2b)!important;
    color:#fff;
    padding:10px;
    border-radius:0 10px 10px 0;
}

/* ===================== MARQUEE ===================== */
.marquee{
    font-weight:600;
    letter-spacing:.5px;
}

/* ===================== TEXT ===================== */
.payment-form p{
    color:#2c3e50;
    font-size:14px;
}

/* ===================== QR POPUP ===================== */
.qr-popup{
    display:none;
    position:fixed;
    top:80px;
    left:50%;
    transform:translateX(-50%);
    width:320px;
    background:#ffffff;
    padding:20px;
    border-radius:18px;
    text-align:center;
    border:4px solid #38ef7d;
    box-shadow:0 15px 40px rgba(0,0,0,.45);
    z-index:9999;
}

.qr-popup img{
    max-width:220px;
    margin:15px auto;
}

.qr-popup button{
    background:linear-gradient(135deg,#ff416c,#ff4b2b);
    border-radius:25px;
}

/* ===================== MOBILE ===================== */
@media(max-width:768px){
    .payment-form{
        margin:20px;
        padding:20px;
    }
}
</style>

		 <div align="center" class="payment-form">

			
				<div 	align="center">

							<h3 class="profile-username text-center"><?php echo $_SESSION['name'] ?></h3>

							<p class="text-muted text-center"><?php echo $_SESSION['usertype'] ?></p>

							<ul class="list-group list-group-unbordered mb-3">
								<li class="list-group-item">
									<b>Mobile</b> <a class="float-right"><?php echo $_SESSION['phone'] ?></a>
								</li>
								<li class="list-group-item">
									<b>Email</b> <a class="float-right"><?php echo $_SESSION['emailid'] ?></a>
								</li>
								<li class="list-group-item">
									<b>Created At</b> <a class="float-right"><?php echo $udata['joineddate'] ?> 19:28:55</a>
								</li>
								<li class="list-group-item">
									<b>Wallet balance</b> <a class="float-right"><b>₹<?php echo $udata['walletamount'] ?></b></a>
								</li>
							</ul>
</div>
						
									<form action="" method="POST" name="profile" class="form-horizontal">
										<div class="form-group row">
											<label for="inputName" class="col-sm-2 col-form-label">Name</label>
											<div class="col-sm-10">
												<input type="name" class="form-control" id="inputName" name="name" value="<?php echo $udata['name'] ?>" placeholder="Name">
											</div>
										</div>
										<div class="form-group row">
											<label for="inputEmail" class="col-sm-2 col-form-label">Email</label>
											<div class="col-sm-10">
												<input type="email" class="form-control" name="email" id="inputEmail" value="<?php echo $udata['emailid'] ?>" placeholder="Email">
											</div>
										</div>
										<input type="hidden" name="s_profile" value="ahkweb">
										<div class="form-group row">
											<label for="inputName2" class="col-sm-2 col-form-label">Phone</label>
											<div class="col-sm-10">
												<input type="text" class="form-control" name="phone" value="<?php echo $udata['phone'] ?>" id="inputName2" placeholder="Phone">
											</div>
										</div>


										<div class="form-group row">
											<div class="offset-sm-2 col-sm-10">
												<button type="submit" class="btn btn-success">Submit</button>
											</div>
										</div>
									</form>
									
									
                                </div>
		<?php 
include('userfooter.php');
?>
