:: **Zploit** v1.0 | Current Path: **/home/kreativepixelz/soulmeetvivah.com/member/php/**
:: Editing File: change-email.php
<?php include('header.php'); ?> <style type="text/css"> /* ============================================ Modern Tab Navigation Styles ============================================ */ .user-top-header { background: #fff; border-radius: 15px; padding: 0; box-shadow: 0 5px 20px rgba(0,0,0,0.1); margin-bottom: 30px; overflow: hidden; } .menu-list { list-style: none; padding: 0; margin: 0; display: flex; background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%); border-bottom: 3px solid #e0e0e0; position: relative; } .menu-list li { position: relative; flex: 1; text-align: center; transition: all 0.3s ease; } .menu-list li:not(:last-child) { border-right: 1px solid rgba(0,0,0,0.1); } .menu-list li a { display: flex; align-items: center; justify-content: center; padding: 18px 20px; text-decoration: none; color: #666; font-weight: 600; font-size: 15px; transition: all 0.3s ease; text-transform: uppercase; letter-spacing: 0.5px; gap: 10px; } .menu-list li a i { font-size: 18px; transition: all 0.3s ease; } .menu-list li:hover:not(.active) a { color: #cd4252; background: rgba(205, 66, 82, 0.05); } .menu-list .active { background: #cd4252; } .menu-list .active a { color: #fff !important; } .block-box { background: white; padding: 20px; border-radius: 10px; margin-bottom: 20px; box-shadow: 0 2px 5px rgba(0,0,0,0.1); } </style> <div style="height: 100px;"></div> <div class="page-content"> <div class="container"> <div class="user-top-header"> <ul class="menu-list"> <li><a href="my-soulmeet"> <i class="icofont-user"></i> <span>My Profile</span> </a></li> <li><a href="my-photos"> <i class="icofont-picture"></i> <span>My Photos</span> </a></li> <li class="active"><a href="settings"> <i class="icofont-settings"></i> <span>Setting</span> </a></li> </ul> </div> <div class="block-box user-about"> <div class="widget-heading"> <h3 style="font-size: 18px!important;">Change Email</h3> </div> <div class="row"> <div class="col-lg-8"> <div id="emailMessage" class="alert" style="display: none; margin-bottom: 20px;"></div> <form id="changeEmailForm"> <div class="form-group mb-3"> <label for="current_email" style="font-weight: 600; color: #333; margin-bottom: 8px;"> <i class="icofont-envelope"></i> Current Email </label> <input type="email" class="form-control" id="current_email" value="<?=$email?>" readonly style="background: #f5f5f5; cursor: not-allowed;"> </div> <div class="form-group mb-3"> <label for="new_email" style="font-weight: 600; color: #333; margin-bottom: 8px;"> <i class="icofont-envelope"></i> New Email Address </label> <input type="email" class="form-control" id="new_email" name="new_email" placeholder="Enter your new email address" required style="border-radius: 8px; padding: 12px 15px;"> <small class="form-text text-muted">Enter a valid email address that is not already registered.</small> </div> <div class="form-group mb-3"> <label for="confirm_email" style="font-weight: 600; color: #333; margin-bottom: 8px;"> <i class="icofont-envelope"></i> Confirm New Email Address </label> <input type="email" class="form-control" id="confirm_email" name="confirm_email" placeholder="Confirm your new email address" required style="border-radius: 8px; padding: 12px 15px;"> <small class="form-text text-muted">Re-enter the new email address to confirm.</small> </div> <div class="text-center" style="margin-top: 30px;"> <button type="button" id="updateEmailBtn" class="btn" style="background: #cd4252; color: #fff; padding: 12px 40px; border-radius: 8px; font-weight: 600; font-size: 16px;"> <i class="icofont-ui-email"></i> Update Email </button> </div> </form> </div> </div> </div> </div> </div> <script> // Wait for jQuery to be available (function() { function initEmailUpdate() { if (typeof jQuery === 'undefined') { console.error('jQuery is not loaded'); setTimeout(initEmailUpdate, 100); return; } jQuery(document).ready(function($) { console.log('Email update script initialized'); // Update Email Button Click $('#updateEmailBtn').on('click', function(e) { e.preventDefault(); e.stopPropagation(); console.log('Update email button clicked'); // Validate and submit var newEmail = $('#new_email').val().trim(); var confirmEmail = $('#confirm_email').val().trim(); var currentEmail = '<?=$email?>'; // Validation if (!newEmail) { showMessage('Please enter a new email address.', 'danger'); $('#new_email').focus(); return false; } if (!confirmEmail) { showMessage('Please confirm your new email address.', 'danger'); $('#confirm_email').focus(); return false; } // Email format validation var emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/; if (!emailRegex.test(newEmail)) { showMessage('Please enter a valid email address.', 'danger'); $('#new_email').focus(); return false; } if (newEmail != confirmEmail) { showMessage('Email addresses do not match!', 'danger'); $('#confirm_email').focus(); return false; } if (newEmail == currentEmail) { showMessage('New email must be different from current email.', 'danger'); $('#new_email').focus(); return false; } // Disable button and show loading var submitBtn = $(this); var originalText = submitBtn.html(); submitBtn.prop('disabled', true).html('<i class="icofont-spinner-alt-4"></i> Updating...'); console.log('Sending AJAX request to update email'); $.ajax({ url: 'php/update_email.php', method: 'POST', data: { user_id: '<?=$user_id?>', new_email: newEmail }, dataType: 'text', success: function(response) { console.log('Email update response:', response); submitBtn.prop('disabled', false).html(originalText); var trimmedResponse = response.trim(); if (trimmedResponse == '1') { showMessage('Email updated successfully!', 'success'); // Clear form $('#new_email').val(''); $('#confirm_email').val(''); setTimeout(function() { location.reload(); }, 2000); } else { var errorMsg = trimmedResponse || 'Failed to update email. Please try again.'; showMessage(errorMsg, 'danger'); } }, error: function(xhr, status, error) { console.error('AJAX Error:', status, error, xhr.responseText); submitBtn.prop('disabled', false).html(originalText); showMessage('An error occurred. Please try again. Error: ' + error, 'danger'); } }); return false; }); // Also handle form submit as backup $('#changeEmailForm').on('submit', function(e) { e.preventDefault(); e.stopPropagation(); $('#updateEmailBtn').click(); return false; }); function showMessage(message, type) { var alertClass = type == 'success' ? 'alert-success' : 'alert-danger'; $('#emailMessage').removeClass('alert-success alert-danger') .addClass(alertClass) .html('<strong>' + (type == 'success' ? 'Success!' : 'Error!') + '</strong> ' + message) .fadeIn(); // Auto-hide success messages after 5 seconds if (type == 'success') { setTimeout(function() { $('#emailMessage').fadeOut(); }, 5000); } } }); } // Start initialization if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', initEmailUpdate); } else { initEmailUpdate(); } })(); </script> <?php include('footer.php'); ?>