Ciao a tutti, e grazie in anticipo per il piccolo aiuto che vi chideo.
Non sono molto pratico di PHP, ci sto lavorando su da poco.
Ho il seguente problema, sembra funzionare un form mail. Ma il mittente non viene sconosciuto.
Come da oggetto risulta che l'email mi è stata spedita da anonymous ecc. ecc.
VI posto gli script HTML, PHP e quelo .js ci sono anche altri 2 .JS non sembra che l'errore possa essere li...se è necessario ve lo posto...
grazie ancora:
Tony
CODICE HTML
Codice PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-GB" xml:lang="en-GB">
<title>Contactable | jQuery Plugin</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
<script type="text/javascript" src="js/jquery.validate.pack.js"></script>
<script type="text/javascript" src="js/jquery.contactable.js"></script>
<link rel="stylesheet" href="css/contactable.css" type="text/css" />
<script>
$(function(){
$('#contact').contactable({
subject: 'Nuovo Messaggio dal sito PDG s.r.l.'
});
});
</script>
</head>
<body>
<div id="contact">
</div>
</body>
</html>
CODICE PHP
Codice PHP:
<?php
//declare our assets
$name = stripcslashes($_POST['name']);
$subject = stripcslashes($_POST['subject']);
$emailAddr = stripcslashes($_POST['email']);
$comment = stripcslashes($_POST['comment']);
$contactMessage = "Messaggio: $comment \r \n Contattato da: $name \r \n Rispondi a: $emailAddr";
//validate the email address on the server side
if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $emailAddr) ) {
//if successful lets send the message
mail('mia email@libero.it', $name, $subject, $emailAddr, $contactMessage);
echo('success'); //return success callback
} else {
echo('An invalid email address was entered'); //email was not valid
}
?>
CODICE .JS
Codice PHP:
/*
* contactable 1.2.1 - jQuery Ajax contact form
*
* Copyright (c) 2009 Philip Beel (http://www.theodin.co.uk/)
* Dual licensed under the MIT (http://www.opensource.org/licenses/mit-license.php)
* and GPL (http://www.opensource.org/licenses/gpl-license.php) licenses.
*
* Revision: $Id: jquery.contactable.js 2010-01-18 $
*
*/
//extend the plugin
(function($){
//define the new for the plugin ans how to call it
$.fn.contactable = function(options) {
//set default options
var defaults = {
name: 'Name',
email: 'Email',
message : 'Messaggio',
subject : 'Messaggio dal sito PDG s.r.l.',
recievedMsg : 'Grazie per averci contattato',
notRecievedMsg : 'Ci dispiace ma il suo messaggio non é stato inviato, riprovi piú tardi',
disclaimer: 'Lascia il tuo messaggio, sarai ricontattato da un nostro incaricato.',
hideOnSubmit: false
};
//call in the default otions
var options = $.extend(defaults, options);
//act upon the element that is passed into the design
return this.each(function(options) {
//construct the form
$(this).html('<div id="contactable"></div><form id="contactForm" method="" action=""><div id="loading"></div><div id="callback"></div><div class="holder"><p><label for="name">Nome <span class="red"> * </span></label><br /><input id="name" class="contact" name="name" /></p><p><label for="email">E-Mail <span class="red"> * </span></label><br /><input id="email" class="contact" name="email" /></p><p><label for="comment">Messaggio <span class="red"> * </span></label><br /><textarea id="comment" name="comment" class="comment" rows="4" cols="30" ></textarea></p><p><input class="submit" type="submit" value="Invia"/></p><p class="disclaimer">'+defaults.disclaimer+'</p></div></form>');
//show / hide function
$('div#contactable').toggle(function() {
$('#overlay').css({display: 'block'});
$(this).animate({"marginLeft": "-=5px"}, "fast");
$('#contactForm').animate({"marginLeft": "-=0px"}, "fast");
$(this).animate({"marginLeft": "+=387px"}, "slow");
$('#contactForm').animate({"marginLeft": "+=390px"}, "slow");
},
function() {
$('#contactForm').animate({"marginLeft": "-=390px"}, "slow");
$(this).animate({"marginLeft": "-=387px"}, "slow").animate({"marginLeft": "+=5px"}, "fast");
$('#overlay').css({display: 'none'});
});
//validate the form
$("#contactForm").validate({
//set the rules for the fild names
rules: {
name: {
required: true,
minlength: 2
},
email: {
required: true,
email: true
},
comment: {
required: true
}
},
//set messages to appear inline
messages: {
name: "",
email: "",
comment: ""
},
submitHandler: function() {
$('.holder').hide();
$('#loading').show();
$.post('mail.php',{subject:defaults.subject, name:$('#name').val(), email:$('#email').val(), comment:$('#comment').val()},
function(data){
$('#loading').css({display:'none'});
if( data == 'success') {
$('#callback').show().append(defaults.recievedMsg);
if(defaults.hideOnSubmit == true) {
//hide the tab after successful submition if requested
$('#contactForm').animate({dummy:1}, 2000).animate({"marginLeft": "-=450px"}, "slow");
$('div#contactable').animate({dummy:1}, 2000).animate({"marginLeft": "-=447px"}, "slow").animate({"marginLeft": "+=5px"}, "fast");
$('#overlay').css({display: 'none'});
}
} else {
$('#callback').show().append(defaults.notRecievedMsg);
}
});
}
});
});
};
})(jQuery);