Visualizzazione dei risultati da 1 a 9 su 9

Discussione: problema form mail

  1. #1

    problema form mail

    Salve a tutti ho un problema con un form mi segnela che l'invio è stato effettuato ma in realtà non mi arriva nulla

    posto il codice

    <?php

    $from = "info@XXXXX.com";
    $from_name = "DesignHQ";
    $subject = "Contact Form";

    $to = $_POST['miamail@msn.com'];

    // collect data
    $body = "";
    foreach($_POST as $key => $val)
    {
    if($key != 'captcha')
    $body .= ucfirst($key).": ".$val."\r\n";
    }

    // construct MIME PLAIN Email headers
    $header = "MIME-Version: 1.0\n";
    $header .= "Content-type: text/plain; charset=utf-8\n";
    $header .= "From: $from_name <$from>\r\nReply-To: $from_name <$from>\r\nReturn-Path: <$from>\r\n";

    // send email
    $mail_sent = mail($to, $subject, $body, $header);
    ?>


    qualcuno mi può aiutare????

  2. #2
    Utente di HTML.it L'avatar di las
    Registrato dal
    Apr 2002
    Messaggi
    1,221
    bisognerebbe vedere il form per essere sicuri, però credo che il problema sia qui:

    $to = $_POST['miamail@msn.com'];

    probabilmente il nome del campo nel form è qualcosa tipo 'email' o 'e-mail' quindi dovresti correggerla con

    $to = $_POST['email'];

    oppure

    $to = $_POST['e-mail'];

    in pratica devi sostituire l'indirizzo vero e proprio con il nome del campo nel form, e ovviamente scrivere correttamente l'indirizzo quado invii il form


  3. #3
    si infatti effettivamente li c'era scritto mail e io pensavo si dovesse aggiungere la mail di destinazione sono stato io infatti a modificarlo ma allora dove va inserita la mail di destinazione?

  4. #4
    Utente di HTML.it
    Registrato dal
    Apr 2011
    Messaggi
    28
    Allora, se la mail di destinazione la prendi da un form, allora la devi prendere dal form tramite un post o un get, usando $to = $_POST['nome_input'], con nome_input che sta per il nome che ha l'input text che sta nel form. Se invece la mail di destinazione la inserisci direttamente in php, allora fai $to = "mail".

  5. #5
    ma allora il codice che ho postato all'inizio va bene
    infatti ho messo
    $to = $_POST['miamail@msn.com'];
    al posto di
    $to = $_POST['mail'];

    giusto?

  6. #6
    Utente di HTML.it L'avatar di las
    Registrato dal
    Apr 2002
    Messaggi
    1,221
    no, non va bene, se la vuoi scrivere tu direttamente senza prenderla dal form devi fare così:

    $to = 'miamail@msn.com';


  7. #7
    potreste dirmi il codice corretto? cioè come va completato

  8. #8
    Utente di HTML.it L'avatar di las
    Registrato dal
    Apr 2002
    Messaggi
    1,221
    se prendi l'indirizzo a cui spedire dal form che compila l'utente il codice è questo:

    Codice PHP:
    <?php

    $from 
    "info@XXXXX.com";
    $from_name "DesignHQ";
    $subject "Contact Form";

    $to $_POST['mail'];

    // collect data
    $body "";
    foreach(
    $_POST as $key => $val)
    {
    if(
    $key != 'captcha')
    $body .= ucfirst($key).": ".$val."\r\n";
    }

    // construct MIME PLAIN Email headers
    $header "MIME-Version: 1.0\n";
    $header .= "Content-type: text/plain; charset=utf-8\n";
    $header .= "From: $from_name <$from>\r\nReply-To: $from_name <$from>\r\nReturn-Path: <$from>\r\n";

    // send email
    $mail_sent mail($to$subject$body$header);
    ?>
    se invece l'indirizzo è fisso e lo vuoi scrivere direttamente nel codice devi fare così:

    Codice PHP:
    <?php

    $from 
    "info@XXXXX.com";
    $from_name "DesignHQ";
    $subject "Contact Form";

    $to 'miamail@msn.com';

    // collect data
    $body "";
    foreach(
    $_POST as $key => $val)
    {
    if(
    $key != 'captcha')
    $body .= ucfirst($key).": ".$val."\r\n";
    }

    // construct MIME PLAIN Email headers
    $header "MIME-Version: 1.0\n";
    $header .= "Content-type: text/plain; charset=utf-8\n";
    $header .= "From: $from_name <$from>\r\nReply-To: $from_name <$from>\r\nReturn-Path: <$from>\r\n";

    // send email
    $mail_sent mail($to$subject$body$header);
    ?>

  9. #9
    ciao ho fatto alcune prove ma qusto form non va comunque mi sono dimenticato di dirti che c'è anche uno scripr javascript ma sia nel php che nel javascript non so dove inserire la mail di destinazione se pui dacci un occhi ti allego tutto


    php

    $from = "info@XXXXX.com";
    $from_name = "DesignHQ";
    $subject = "Contact Form";

    $to = $_POST['email'];

    // collect data
    $body = "";
    foreach($_POST as $key => $val)
    {
    if($key != 'captcha')
    $body .= ucfirst($key).": ".$val."\r\n";
    }

    // construct MIME PLAIN Email headers
    $header = "MIME-Version: 1.0\n";
    $header .= "Content-type: text/plain; charset=utf-8\n";
    $header .= "From: $from_name <$from>\r\nReply-To: $from_name <$from>\r\nReturn-Path: <$from>\r\n";

    // send email
    $mail_sent = mail($to, $subject, $body, $header);



    javascript

    function input_focus(id)
    {
    $("#l"+id).addClass('lcurrent');
    }

    function input_blur(id)
    {
    $("#l"+id).removeClass('lcurrent');
    }

    function sendContact()
    {
    // check for email
    var email = $("#email").val();
    var filter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
    if(!filter.test(email))
    {
    $("#email-error").slideDown(500);
    $("#email").focus();
    return false;
    }
    else
    $("#email-error").slideUp(500);

    // check for message
    var msg = $("#message").val();
    if(msg.length == 0)
    {
    $("#message-error").slideDown(500);
    $("#message").focus();
    return false;
    }
    else
    $("#message-error").slideUp(500);

    // check for captcha
    var captcha = $("#captcha").val();
    if(captcha != captcha_c)
    {
    $("#captcha-error").slideDown(500);
    $("#captcha").focus();
    return false;
    }
    else
    $("#captcha-error").slideUp(500);

    var data = $("#contact_form > form").serialize();

    $.ajax({
    type: "POST",
    url: "sendContact.php",
    data: data,
    cache: false,
    success: function(msg){
    }
    });

    $("#contact_form").fadeOut(1000, function() {
    $("#message_sent").slideDown(500);
    });


    return false;
    }

    var captcha_a = Math.ceil(Math.random() * 10);
    var captcha_b = Math.ceil(Math.random() * 10);
    var captcha_c = captcha_a + captcha_b;
    function generate_captcha(id)
    {
    var id = (id) ? id : 'lcaptcha';
    $("#"+id).html(captcha_a + " + " + captcha_b + " = ");
    }

    var jGalleryTimer = 0;
    var jGalleryFirstStart = true;
    var jGallery_action = false;
    function jGallery(id, visible, timeInterval, transitionInterval)
    {
    var visible = (visible) ? visible : 1;
    var timeInterval = (timeInterval) ? timeInterval : 5000;
    var transitionInterval = (transitionInterval) ? transitionInterval : 200;
    var w = (w) ? w : $("."+id+"-gallery-div :first").width();
    var cnt = $("#gallery-"+id+"-holder > div").size();

    if(jGalleryTimer)
    {
    clearInterval(jGalleryTimer);
    jGalleryTimer = 0;
    }

    if(!jGalleryFirstStart)
    {
    if(!jGallery_move(id, cnt, -1, w, visible, transitionInterval))
    jGallery_restart(id, cnt, transitionInterval);
    }

    jGalleryFirstStart = false;

    jGalleryTimer = setInterval(function(){ jGallery(id, visible, timeInterval, transitionInterval); }, timeInterval);
    }

    function jGallery_move(id, cnt, dir, w, visible, transitionInterval)
    {
    if(jGallery_action)
    return false;

    var curr = document.getElementById("gallery-"+id+"-holder").style.left;
    curr = parseFloat(curr);

    if(isNaN(curr))
    curr = 0;
    if(dir > 0)
    {
    if(curr >= 0)
    return false;
    }
    else
    {
    if(curr + cnt * w - visible * w <= 0)
    return false;
    }

    jGallery_action = true;
    var offset = w;

    if(dir < 0)
    dir = "-";
    else
    dir = "+";

    $("#gallery-"+id+"-holder").animate(
    {left : dir+"="+offset+"px"},
    {queue:true, duration:transitionInterval, complete: function() {jGallery_action = false;}}
    );

    return true;
    }

    function jGallery_restart(id, cnt, transitionInterval)
    {
    if(jGallery_action)
    return false;

    var curr = document.getElementById("gallery-"+id+"-holder").style.left;
    curr = parseFloat(curr);

    if(isNaN(curr))
    curr = 0;
    if(curr >= 0)
    return false;

    jGallery_action = true;
    var offset = curr * (-1);

    $("#gallery-"+id+"-holder").animate(
    {left : "+="+offset+"px"},
    {queue:true, duration:transitionInterval*cnt, complete: function() {jGallery_action = false;}}
    );

    return true;
    }

    var jMenu_timeout = 500;
    var jMenu_effectTime = 200;
    var jMenu_closetimer = 0;
    var jMenu_ddmenuitem = 0;
    var jMenu_openid = 0;
    var jMenu_action = false;
    function jMenu_open()
    {
    jMenu_canceltimer();

    if($("a", this).html() == jMenu_openid)
    return;

    if(jMenu_action)
    return;

    jMenu_close();

    if($("ul", this).size() == 0)
    return;

    jMenu_action = true;
    jMenu_ddmenuitem = $(this).find('ul').slideDown(jMenu_effectTime, function() {jMenu_action = false;});
    jMenu_openid = $("a", this).html();
    if (document.getElementById('ul'))
    document.getElementById('ul').className = 'current';
    }

    function jMenu_close()
    {
    if(jMenu_action)
    return;

    if(jMenu_ddmenuitem)
    {
    jMenu_action = true;
    jMenu_ddmenuitem.fadeOut(jMenu_effectTime, function() {jMenu_action = false;});
    jMenu_ddmenuitem = null;
    jMenu_openid = null;
    }
    }

    function jMenu_timer()
    {
    jMenu_closetimer = window.setTimeout(jMenu_close, jMenu_timeout);
    }

    function jMenu_canceltimer()
    {
    if(jMenu_closetimer)
    {
    window.clearTimeout(jMenu_closetimer);
    jMenu_closetimer = null;
    }
    }

    $(document).ready(function() {
    $('#jMenu > li').bind('mouseover', jMenu_open)
    $('#jMenu > li').bind('mouseout', jMenu_timer)
    $('#jMenu > li > ul').bind('mouseover', jMenu_canceltimer)
    $('#jMenu > li > ul > li').bind('mouseover', jMenu_canceltimer)
    });

    document.onclick = jMenu_close;


    cosa mi dici?

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.