<?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>
        .payment-form {
            max-width: 1000px;
            margin: auto;
            background: #fff;
            padding: 20px;
            border-radius: 10px;
            box-shadow: 0 4px 10px rgb(0 0 0 / 80%);
        }

        .payment-form input {
            width: calc(100% - 20px);
            padding: 10px;
            margin: 10px 0;
            border: 1px solid #ccc;
            border-radius: 5px;
        }

        .payment-form button {
            width: 100%;
            padding: 10px;
            background: #28a745;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }

        .payment-form button:hover {
            background: #218838;
        }

        .qr-popup {
            display: none;
            position: fixed;
            top: 70px;
            left: 50%;
            transform: translateX(-50%);
            width: 300px;
            background: rgb(255, 255, 255);
            justify-content: center;
            padding: 20px;
            border-radius: 10px;
            text-align: center;
            color: #181818;
            border: 5px solid #28a745;
            /* Add a 5px border with green color */
            box-shadow: 0px 4px 10px rgba(0, 0, 0, 0.2);
            /* Optional: Add a shadow for better styling */
        }

        .qr-popup img {
            max-width: 200px;
            margin: 10px auto;
        }

        .qr-popup button {
            margin-top: 10px;
            padding: 10px;
            background: #dc3545;
            color: #fff;
            border: none;
            border-radius: 5px;
            cursor: pointer;
        }
    </style>        
                   <div class="payment-form">
									<form action="" name="pass" method="POST" class="form-horizontal">
										<div class="form-group row">
											<label for="inputName" class="col-sm-2 col-form-label">Password</label>
											<div class="col-sm-10">
												<input type="hidden" name="s_password" value="ahkwebsolutions">
												<input type="password" class="form-control" id="inputName" name="password" placeholder="Password">
											</div>
										</div>
										<div class="form-group row">
											<label for="inputEmail" class="col-sm-2 col-form-label">Confirm Password</label>
											<div class="col-sm-10">
												<input type="password" class="form-control" id="inputEmail" name="cpassword" placeholder="Confirm Password">
											</div>
										</div>




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