all page refresh time. Below is my code:
HTML 5:
<form method="post" data-ajax="false"> <input type="text" name="email" placeholder=" jack@example.com , jil@example.com "> <input type="submit" name="submit" value="Invite" class="submitBtn"> </form>
JS:
$('form').bind('submit',function(){ $.ajax({ type : 'POST', url : 'data/invite.php', data : $(this).serialize(), cache : false, dataType: 'text', success : function (serverResponse) { alert('mail sent successfully.'); }, error : function (jqXHR, textStatus, errorThrown) {alert('error sending mail');} }); })
PHP:
<?php $to = $_POST['mail']; $name = 'Indusnet Technologies'; $subject = 'Think Recycle'; $text = 'Welcome to our site'; $message =' You received a mail from '.$name; $message .='Text of the message : '.$text; if(mail($to, $subject,$message)){ echo 'mail successful send'; } else{ echo 'there's some errors to send the mail, verify your server options'; } ?>
source share