I have code send from to mail, and I don't broke this code. i don't know the page action receive the form info .. I wont code send to tow direction, in the same time like this .
<from action ="firstdiraction.php" action="seconddirction.php" >
</div>
Using jQuery and AJAX:
<form id="my_form" action="javascript:sendForm()">
Form...
</form>
<script type="text/javascript" src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script type="text/javascript">
function sendForm() {
var form = $('#my_form');
$.ajax({
type: "POST",
url: 'firstdiraction.php',
data: form.serialize(),
success: function(response) {
console.log(response);
}
});
$.ajax({
type: "POST",
url: 'seconddirction.php',
data: form.serialize(),
success: function(response) {
console.log(response);
}
});
}
</script>
Okay so you want to send form data to two different php scripts, this can be done via ajax like :
$(document).ready( function(){
$('#SubmitButton').click(function(){
//Send data to the email script
$.post( 'firstdiraction.php', $('form').serialize(), function(data, textStatus) {
//data is the result from the script
alert(data);
});
//Send data to the other script
$.post( 'seconddirction.php', $('form').serialize(), function(data, textStatus) {
//data is the result from the script
alert(data);
});
});
});
Above will get triggered on press of submit button inside your form tag <form> </form>
jQuery
aslo required, include it on your page.