• User Newbie

    Problema form....

    Buongiorno ho un form che mi manda nome cognome telefono mail e messaggio a un indirizzo mail allego codice:

    <?php     $emailTo = '[email protected]';
        if($subject!=""){
        $subject =$_REQUEST['subject'];
        }else{
        $subject = 'Richiesta informazioni dal sit';
        }
        $name=$_REQUEST['name'];
        $telefono=$_REQUEST['telefono'];
        $email=$_REQUEST['email'];
        $msg=$_REQUEST['msg'];
        
        $body = "Nome: $name \n\nEmail: $email \n\nTelefono: $telefono \n\nMessaggio: $msg \n\n ";
        $headers = 'From: '.$name.' <'.$email.'>' . "\r\n" . 'Reply-To: ' . $email;
        
        mail($emailTo, $subject, $body, $headers);
    ?>
    

    e il codice in js

    jQuery(function() {  jQuery('.error').hide();
      jQuery(".button").click(function() {
    
    
        jQuery('.error').hide();
            
          var name = jQuery("input#name").val();
            if (name == "") {
          jQuery("span#name_error").show();
          jQuery("input#name").focus();
          return false;
        }
          var telefono = jQuery("input#telefono").val();
            if (telefono == "") {
          jQuery("span#telefono_error").show();
          jQuery("input#telefono").focus();
          return false;
        }    
         
        if((isNaN(telefono))) {
        jQuery("span#telefono_error2").show();
        jQuery("input#telefono").focus();
          return false;
        }
     
          var email = jQuery("input#email").val();
          if (email == "") {
          jQuery("span#email_error").show();
          jQuery("input#email").focus();
          return false;
        }
        
        var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
        if(!emailReg.test(email)) {
        jQuery("span#email_error2").show();
        jQuery("input#email").focus();
          return false;
        }
        var subject = jQuery("input#subject").val();
        
          var msg = jQuery("textarea#msg").val();
          if (msg == "") {
          jQuery("span#msg_error").show();
          jQuery("textarea#msg").focus();
          return false;
        }
            
            var dataString = 'name='+ name + '&email=' + email +  '&telefono=' + telefono + '&subject=' + subject + '&msg=' + msg;
    
    
            
          jQuery.ajax({
          type: "POST",
          url: "process.php",
          data: dataString,
          success: function() {
            jQuery('#contactform').html("<div id='message' class='ten columns'></div>");
            jQuery('#message').html("<strong>La vostra richiesta è stata inviata!</strong>")
            .append("<p>Vi ricontatteremo il prima possibile.</p>")
            .hide()
            .fadeIn(1500, function() {
              jQuery('#message');
            });
          }
         });
        return false;
        });
    });
    
    
    
    

    il mio problema e' che il telefono non mi compare nella mail di ritorno..... qualcuno puo' aiutarmi? sto impazendo:x
    grazie mille!


  • User Attivo

    if((isNaN(telefono))) { jQuery("span#telefono_error2").show(); jQuery("input#telefono").focus(); return false; }

    Questo controlla che il numero non sia nullo ma se controlli già sopra il valore non è utile.

    Fai un po' di prove inserendo un testo al posto del numero di telefono e vedi se passa i dati.
    A colpo d'occhio non mi sembra di vedere nulla di strano.
    Attendo novità.