mam problem z kodem dotyczącym formularza oraz wysyłania maila z załącznikiem:
Właściwie problem zaczyna się już na samym początku.. nie wiem dlaczego wtyczka validate nie chce przeprowadzić walidacji...
Wpierw formularz:
Tutaj wtyczka validate i kod umiszczony w $(document).ready(function() {});
Kod
$('#mail').validate({
rules: {
email: {
required: true,
email: true
},
name: {
required: true
},
message: {
required: true,
rangelength:[50,300]
}
}, //koniec literału obiektowego rules
messages: {
email: {
required: "<h3>Podaj adres e-mail.</h3>",
email: "<h3>To nie jest prawidłowy <br>adres e-mail.</h3>"
},
name: {
required: "<h3>Podaj swoje imię i nazwisko.</h3>"
},
message: {
required: "<h3>Wpisz treść listu motywacyjnego.</h3>",
rangelength: "<h3>List motywacyjny powinien mieć od 50 do 300 znaków.</h3>"
}
},
submitHandler: function() {
var thisForm = $('form');
$('form').fadeOut(function(){
//Display the "loading" message
$("#loading").fadeIn(function(){
//Post the form to the send script
$.ajax({
type: 'POST',
url: thisForm.attr("action"),
data: thisForm.serialize(),
//Wait for a successful response
success: function(data){
//Hide the "loading" message
$("#loading").fadeOut(function(){
//Display the "success" message
$("#success").text(data).fadeIn();
}
});
});
});
}
}); // koniec funkcji validate
rules: {
email: {
required: true,
email: true
},
name: {
required: true
},
message: {
required: true,
rangelength:[50,300]
}
}, //koniec literału obiektowego rules
messages: {
email: {
required: "<h3>Podaj adres e-mail.</h3>",
email: "<h3>To nie jest prawidłowy <br>adres e-mail.</h3>"
},
name: {
required: "<h3>Podaj swoje imię i nazwisko.</h3>"
},
message: {
required: "<h3>Wpisz treść listu motywacyjnego.</h3>",
rangelength: "<h3>List motywacyjny powinien mieć od 50 do 300 znaków.</h3>"
}
},
submitHandler: function() {
var thisForm = $('form');
$('form').fadeOut(function(){
//Display the "loading" message
$("#loading").fadeIn(function(){
//Post the form to the send script
$.ajax({
type: 'POST',
url: thisForm.attr("action"),
data: thisForm.serialize(),
//Wait for a successful response
success: function(data){
//Hide the "loading" message
$("#loading").fadeOut(function(){
//Display the "success" message
$("#success").text(data).fadeIn();
}
});
});
});
}
}); // koniec funkcji validate
oraz kod php który wogóle nie wysyła mi żadnych informacji z pól formularza oraz błędnie wysyła załącznik... czy mógłby mi ktoś pomoc ?
<?php foreach($_FILES as $name=>$file) { $file_name = $file['name']; $temp_name = $file['tmp_name']; $file_type = $file['type']; $ext = $path_parts['extension']; } } // email fields: to, from, subject, and so on $to = "dawid.zaik@gmail.com"; $from = $_POST['email']; $subject ="Formularz aplikacyjny"; $message = $_POST['message']; $imie = $_POST['name']; $headers = "From: $name $from"; // boundary $mime_boundary = "==Multipart_Boundary_x{$semi_rand}x"; // headers for attachment $headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\""; // multipart boundary $message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/plain; charset=\"iso-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n"; $message .= "--{$mime_boundary}\n"; // preparing attachments for($x=0;$x<count($files);$x++){ $message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$files[$x]\"\n" . "Content-Disposition: attachment;\n" . " filename=\"$files[$x]\"\n" . "Content-Transfer-Encoding: base64\n\n" . $data . "\n\n"; $message .= "--{$mime_boundary}\n"; } // send } ?>