0
Я пытаюсь передать форму для $ .ajax, но когда я доберусь до части успеха: блок функций (данных) .... Я ' м не эксперт в этом и просто начать заниматься программированием, если кто-то достаточно любезен, чтобы объяснить, как poderme отправить «Notify», вот мой код:
<script>
$(function () {
$("#contacto_web").submit(function(e) {
e.preventDefault();
$.ajax({
url : "contacto_web.php",
type : "POST",
data : {
$("#contacto_web").serialize();
},
before : function() {
},
success : function (data) {
if(data == "si_enviado"){
$UIkit.notify({
message : 'Bazinga!',
status : 'info',
timeout : 5000,
pos : 'top-center'
});
}else if(data == "no_enviado"){
$UIkit.notify({
message : 'Bazinga!',
status : 'danger',
timeout : 5000,
pos : 'top-center'
});
}
},
error : function() {
},
});
});
});
</script>
UIKit Framework Ссылка:
php code:
<?php
if(filter_input_array(INPUT_POST)){
$nombres = filter_input(INPUT_POST, "nombres");
$apellidos = filter_input(INPUT_POST, "apellidos");
$tlfno1 = filter_input(INPUT_POST, "tlfno1");
$tlfno2 = filter_input(INPUT_POST, "tlfno2");
$email1 = filter_input(INPUT_POST, "email1");
$email2 = filter_input(INPUT_POST, "email2");
$nombre_razonsocial = filter_input(INPUT_POST, "nombre_razonsocial");
$pais = filter_input(INPUT_POST, "pais");
$direccion = filter_input(INPUT_POST, "direccion");
$sms_form = filter_input(INPUT_POST, "sms_form");
$to = "[email protected]";
$title = "Correo de contacto desde la pagina web";
$headers = "From: $email1" . "\r\n";
$message ="
Contacto desde la pagina web\n
$nombres $apellidos\n
Telefono $tlfno1 | Movil $tlfno2\n
Correo principal $email1, Correo alternativo $email2\n\n
Nombre/Razon social $nombre_razonsocial\n
Pais de procedencia $pais\n
Direccion $direccion\n
Mensaje\n
$sms_form
";
if(mail($to,$title,$message,$headers)){
echo "si_enviado";
}else{
echo "no_enviado";
}
}