Pozdrav,
evo napravila sam, skoro…
Pošalje mail ali bez podataka… Gdje sam fulala?
Evo ga kod:
JS
console.log('It works');
// alert('It works');
$(document).ready(function (){
$('#submit-bm').click(function (event){
event.preventDefault()
console.log('Clicked!')
var com = $('#company').val();
var per = $('#person').val();
var phn = $('#phone').val();
var eml = $('#email').val();
var nte = $('#note').val();
var dataBM = 'com1=' + com + '&per1=' + per + '&phn1=' + phn + '&eml1=' + eml + '&nte1=' + nte;
console.log(dataBM)
alert(dataBM);
if(com==''|| per==''|| phn=='' || eml==''|| nte==''){
$('#status').html(
' <div class="alert alert-warning alert-dismissible fade show">\n' +
' <button type="button" class="close" data-dismiss="alert">×</button>\n' +
' Molimo popunite sva polja.\n' +
' </div>')
}
else{
$.ajax({
type: 'POST',
url: 'mail/becomemember.php',
data: dataBM,
cache: false,
dataType: 'html',
success: function(){
$('#status').html(
' <div class="alert alert-success alert-dismissible fade show">\n' +
' <button type="button" class="close" data-dismiss="alert">×</button>\n' +
' Vaš zahtjev je uspješno poslan.\n' +
' </div>')
}
});
}
return false;
})
})
PHP
$com = $POST[“com1”];
$per = $POST[“per1”];
$phn = $POST[“phn1”];
$eml = $POST[“eml1”];
$nte = $POST[“nte1”];
$to = ‘mail@gmail.com’;
$subject = ‘Zahtjev’;
$headers = ‘MIME-Version: 1.0’. “\r\n”;
$headers .= ‘Content-type:text/html;charset=UTF-8’. “\r\n”;
$message = 'This message is from '.$com;
mail($to, $subject, $headers,$message);