Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/379.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 传递表单值以发送邮件_Javascript_Php_Jquery_Forms_Email - Fatal编程技术网

Javascript 传递表单值以发送邮件

Javascript 传递表单值以发送邮件,javascript,php,jquery,forms,email,Javascript,Php,Jquery,Forms,Email,这是我的表格(HTML): 邮件有这么多的可能性,但至少检查一下mail()本身是否正在重新调整您的post变量?@Dagon:mail运行正常。前一段时间,同样的表单工作了,然后我不得不更改验证过程,现在邮件发送不再工作(相同的主机)@j08691:对不起。。需要再详细一点。。我该怎么做D.var\u dump($\u POST) <form id="contact_form" name="contact_form" method="post" action="<?php echo

这是我的表格(HTML):


邮件有这么多的可能性,但至少检查一下
mail()
本身是否正在重新调整您的post变量?@Dagon:mail运行正常。前一段时间,同样的表单工作了,然后我不得不更改验证过程,现在邮件发送不再工作(相同的主机)@j08691:对不起。。需要再详细一点。。我该怎么做D.
var\u dump($\u POST)
<form id="contact_form" name="contact_form" method="post" action="<?php echo htmlentities($_SERVER['SCRIPT_NAME']); ?>">
    <input type="text" placeholder="Nome e cognome" name="nome" id="nome" style="width:290px">
    <br>
    <br>
    <input type="text" placeholder="Azienda" name="azienda" id="azienda" style="width:290px">
    <br>
    <br>
    <input type="text" placeholder="Città" name="citta" id="citta" style="width:290px">
    <br>
    <br>
    <input type="text" placeholder="Recapito telefonico" name="telefono" id="telefono" style="width:290px">
    <br>
    <br>
    <input type="text" placeholder="Email" name="email" id="email" style="width:290px">
    <br>
    <br>
    <input type="text" placeholder="Tipo di evento" name="tipodievento" id="tipodievento" style="width:290px">
    <br>
    <br>
    <input type="text" placeholder="Numero di invitati stimato" name="invitati" id="invitati" style="width:290px">
    <br>
    <br>
    <textarea placeholder="Descrizione" style="max-width:600px;max-height:400px;width:290px;height:200px" name="messaggio" id="messaggio">
    </textarea>
    <br>
    <br>
    <div id="boingdiv" style="width:300px;position:relative;">
        <input type="checkbox" name="checkbox" id="checkbox" />
        <small> Ho preso visione dell'<a style="color:#b40734" href="images/contatti/informativa.pdf" target="_blank">informativa</a></small>
    </div>
    <br>
    <br>
    <input id="submit_it" name="submit_it" type="button" value="Invia">
</form>
arrValidate = ['nome','citta','telefono','email','tipodievento','invitati','messaggio']

$(document).ready(function() {

    $('#submit_it').click(function() {
        var nextFld, i ;

        //Validate the checkbox:
        if ( $('#checkbox').is(':checked') == false ) {
            alert('You must read the informativa and check the checkbox at bottom of form');
            boing();
            return false;
        }

        //Validate the rest of the fields
        for (i=0; i<arrValidate.length; i++){
            nextFld = arrValidate[i];
            if ( $.trim($('#'+nextFld).val()) == '') {
                alert('Please complete all fields. You missed the ['  +nextFld+ '] field.');
                $('#'+nextFld).css({'border':'1px solid red','background':'yellow'});
                $('#'+nextFld).focus();
                return false;
            }
        }

        //if it gets here, all is okay: submit!
        $('form#contact_form').submit();
    }); //END submit button click event

    //Remove any css validation coloring
    $('input:not([type=button])').blur(function(){
        $(this).css({'border':'1px solid lightgrey','background':'white'});
    });
    //Remove any background coloring from checkbox div
    $('#checkbox').click(function() {
        $('#boingdiv').css({'background':'white'});
    });
    //Remove existing value/text upon entry into field
    $('input:not([type=button]').focus(function() {
        $(this).val('');
    });

}); //END document.ready

function boing(){
    $('#boingdiv')
        .css({'background':'wheat'})
        .animate({ left: "-10px" }, 100).animate({ left: "10px" }, 100)
        .animate({ left: "-10px" }, 100).animate({ left: "10px" }, 100)
        .animate({ left: "0px" }, 100)
        .focus();
}
<?php
$your_email ='MY EMAIL ADDRESS';

if(isset($_POST['submit_it']))
{

    $nome = $_POST['nome'];
    $email = $_POST['email'];
    $citta = $_POST['citta'];
    $telefono = $_POST['telefono'];
    $tipodievento = $_POST['tipodievento'];
    $invitati = $_POST['invitati'];
    $azienda = $_POST['azienda'];
    $messaggio = $_POST['messaggio'];


        $to = $your_email;
        $subject="Nuova mail dal form per i contatti";
        $from = $your_email;

        $body = "$nome ha inviato un messaggio tramite il contact form:\n".
        "Nome: $nome\n".
        "Citta: $citta\n".
        "Evento: $tipodievento\n".
        "Azienda: $azienda\n".
        "Numero di invitati: $invitati\n".
        "Telefono: $telefono\n".
        "Email: $email \n".
        "Messaggio: \n".
        "$messaggio\n";

        $headers = "From: $from \r\n";
        $headers .= "Reply-To: $email \r\n";

        mail($to, $subject, $body, $headers);
}
?>