I am trying to create a email invite form where the user inputs their friend’s email address and an email is sent to that friend with further instructions on how to sign up for the website.
My question is this: how do I use AJAX to store the email address that the user submits to mySQL database?
Here is the snippet of code that the author of the email invite form demo said to use “ajax() call to pass the address into your database”:
function completeInviteForm() {
setTimeout(function() {
$("#completeform").fadeOut(400, function(){
$(this).before('<span class="msg">All set! We will be in touch.</span>');
});
}, 1100);
}
You can not use AJAX to store the email in the database but what you can do is pass the email address from the client-side to server-side. Then at the PHP level you can store the email address in the database.
AJAX Call
PHP – database.php