// Perform AJAX request to send confirmation email var xhr = new XMLHttpRequest(); xhr.open('POST', 'send_confirmation_email.php'); xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded'); xhr.onload = function () { if (xhr.status === 200) { alert('Confirmation email sent successfully to ' + username); } else { alert('Error sending confirmation email'); } }; xhr.send('username=' + username);