Visualizzazione dei risultati da 1 a 2 su 2
  1. #1

    Aiuto per form contatti

    Dopo tre ore passate a cercare di capire cosa non funziona mi rivolgo a voi con la speranza di risolvere quello che per me è un vero e proprio arcano.

    Da quando ho iniziato a programmare siti Internet ho sempre usato un semplice form per la sezione contatti che ha non mi ha mai dato problemi. Ora, avendo la necessità di aggiungere alcuni campi nel form per trasformarlo in un modulo di iscrizione ad un convegno, ho scritto alcune righe aggiuntive in php e non capisco perchè non mi arrivano più le mail con i dati inseriti.

    Il modello base del modulo (quello che funziona) è questo:

    modulo.php
    Codice PHP:
    <html>
    <
    head>
    <
    title>Modulo per guestbook</title>
    <
    style type="text/css">
    (...........)
    </
    style>
    <
    script language="javascript" type="text/javascript">
     <!--
      function 
    Modulo() {

            if ((
    document.modulo.nome.value == "")) {
               
    alert("Il campo Nome è obbligatorio");
               
    document.modulo.nome.focus();
               return 
    false;
            }

            else if ((
    document.modulo.email.value == "")) {
              
    alert("Il campo Email è obbligatorio");
              
    document.modulo.email.focus();
              return 
    false;
            }

            else if ((
    document.modulo.messaggio.value == "")) {
               
    alert("Il campo Messaggio è obbligatorio");
               
    document.modulo.messaggio.focus();
               return 
    false;
            }

            else {
               
    document.modulo.action "mailto.php";
               
    document.modulo.submit();
            }
      }
     
    //-->
    </script>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"></head>
    <body>
    <form method="post" name="modulo" action="mailto.php">
    <table border="0" bgcolor="#FF9933" cellspacing="2" cellpadding="2">
      <tr>
        <td width="68"><span class="Stile29">Nome:</span></td>

        <td width="322"><input type="text" size="36" name="nome" maxlength="30"></td>
      </tr>
      <tr>
        <td><span class="Stile29">Email:</span></td>
        <td><input type="text" size="36" name="email" maxlength="30"></td>
      </tr>
      <tr>
        <td><span class="Stile29">Messaggio:</span></td>
        <td><textarea rows="7" cols="60" name="messaggio"></textarea></td>
      </tr>
      <tr>
      <td></td>
      <td> <input type="button" value="Invia" onClick="Modulo()"> <input type="reset" value="Reset">    </td>
      </tr>
    </table>
     </form>
    </body>
    </html> 
    mailto.php
    Codice PHP:
    <?php
    //varie info per email
    $oggi date("j F Y G:i");
    $sito "http://www.crocediserra.it";
    $ip "$_SERVER[REMOTE_ADDR]";
    $browser "$_SERVER[HTTP_USER_AGENT]";
    $to "miogiu@aruba.it, [email]altheovalentini@hotmail.com[/email], [email]tiberio.cesare@hotmail.it[/email]";
    $soggetto "Messaggio per il guestbook";

    if(
    trim($_POST['nome']) == "" OR trim($_POST['email']) == "" OR trim($_POST['messaggio']) == "") {
    echo 
    "<font color=\"#FF0000\" face=\"verdana\" size=\"2\">[b]Tutti i campi sono obbligatori[/b]</font>";

    } else {

    $body "Modulo inviato il $oggi da $ip - $browser \n\n";
    $body .= "Nome: $_POST[nome] \nEmail: $_POST[email] \nMessaggio: $_POST[messaggio]";

    mail("$to","$soggetto","$body");
    ?>
    <html>
    <head>
    (.............)
    </head>
    <body>
    (.............)
    </body>
    </html>
    <?php
    }
    ?>

    QUESTE SONO LE MODIFICHE CHE HO APPORTATO

    modulo.php
    Codice PHP:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3c.org/TR/1999/REC-html401-19991224/loose.dtd">
    <
    html>
    <
    head>
    <
    meta http-equiv="Content-Language" content="it">
    <
    meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <
    title>Centro Studi Città di Foligno</title>
    <
    LINK REL="stylesheet" TYPE="text/css" HREF="style.css">
    <
    script language="javascript" type="text/javascript">
     <!--
      function 
    Modulo() {

            if ((
    document.modulo.nome.value == "")) {
               
    alert("Il campo Nome è obbligatorio");
               
    document.modulo.nome.focus();
               return 
    false;
            }

            else if ((
    document.modulo.cognome.value == "")) {
              
    alert("Il campo Cognome è obbligatorio");
              
    document.modulo.cognome.focus();
              return 
    false;
            }

            else if ((
    document.modulo.cf.value == "")) {
              
    alert("Il campo C.F. è obbligatorio");
              
    document.modulo.cf.focus();
              return 
    false;
            }

            else if ((
    document.modulo.ente.value == "")) {
              
    alert("Il campo Ente/Azienda è obbligatorio");
              
    document.modulo.ente.focus();
              return 
    false;
            }

            else if ((
    document.modulo.ruolo.value == "")) {
              
    alert("Il campo Ruolo è obbligatorio");
              
    document.modulo.ruolo.focus();
              return 
    false;
            }

            else if ((
    document.modulo.professione.value == "")) {
              
    alert("Il campo Professione è obbligatorio");
              
    document.modulo.professione.focus();
              return 
    false;
            }

            else if ((
    document.modulo.indirizzo.value == "")) {
              
    alert("Il campo Indirizzo è obbligatorio");
              
    document.modulo.indirizzo.focus();
              return 
    false;
            }

            else if ((
    document.modulo.cap.value == "")) {
              
    alert("Il campo CAP è obbligatorio");
              
    document.modulo.cap.focus();
              return 
    false;
            }

            else if ((
    document.modulo.citta.value == "")) {
              
    alert("Il campo Città è obbligatorio");
              
    document.modulo.citta.focus();
              return 
    false;
            }

            else if ((
    document.modulo.provincia.value == "")) {
              
    alert("Il campo Provincia è obbligatorio");
              
    document.modulo.provincia.focus();
              return 
    false;
            }

            else if ((
    document.modulo.telefono.value == "")) {
              
    alert("Il campo Telefono è obbligatorio");
              
    document.modulo.telefono.focus();
              return 
    false;
            }

            else if ((
    document.modulo.email.value == "")) {
              
    alert("Il campo Email è obbligatorio");
              
    document.modulo.email.focus();
              return 
    false;
            }
            
            else if ((
    document.modulo.socio.value == "")) {
              
    alert("Il campo Socio è obbligatorio");
              
    document.modulo.socio.focus();
              return 
    false;
            }

            else {
               
    document.modulo.action "mailto.php";
               
    document.modulo.submit();
            }
      }
     
    //-->
    </script></head>

    <body>
    <form method="post" name="modulo" action="mailto.php">
    <table border="0" cellspacing="1" cellpadding="1">
      <tr>
        <td valign="middle"><span class="Stile29">Nome:</span></td>
        <td><input type="text" size="36" name="nome" maxlength="30"></td>
      </tr>
      <tr>
        <td valign="middle"><span class="Stile29">Cognome:</span></td>
        <td><input type="text" size="36" name="cognome" maxlength="30"></td>
      </tr>
      <tr>
        <td valign="middle"><span class="Stile29">C.F.:</span></td>
        <td><input type="text" size="36" name="cf" maxlength="16"></td>
      </tr>
      <tr>
        <td valign="middle"><span class="Stile29">Ente/Azienda:</span></td>
        <td><input type="text" size="36" name="ente" maxlength="30"></td>
      </tr>
      <tr>
        <td valign="middle"><span class="Stile29">Ruolo:</span></td>
        <td><input type="text" size="36" name="ruolo" maxlength="30"></td>
      </tr>
      <tr>
        <td valign="middle"><span class="Stile29">Professione:</span></td>
        <td><input type="text" size="36" name="professione" maxlength="30"></td>
      </tr>
      <tr>
        <td valign="middle"><span class="Stile29">Indirizzo:</span></td>
        <td><input type="text" size="36" name="indirizzo" maxlength="30"></td>
      </tr>
      <tr>
        <td valign="middle"><span class="Stile29">CAP:</span></td>
        <td><input type="text" size="36" name="cap" maxlength="5"></td>
      </tr>
      <tr>
        <td valign="middle"><span class="Stile29">Città:</span></td>
        <td><input name="citta" type="text" id="citta" size="36" maxlength="30"></td>
      </tr>
      <tr>
        <td valign="middle"><span class="Stile29">Provincia:</span></td>
        <td><input type="text" size="36" name="provincia" maxlength="30"></td>
      </tr>
      <tr>
        <td valign="middle"><span class="Stile29">Telefono:</span></td>
        <td><input type="text" size="36" name="telefono" maxlength="30"></td>
      </tr>
      <tr>
        <td valign="middle"><span class="Stile29">[i]Fax:[/i]</span></td>
        <td><input type="text" size="36" name="fax" maxlength="30"></td>
      </tr>
      <tr>
        <td valign="middle"><span class="Stile29">[i]Cellulare:[/i]</span></td>
        <td><input type="text" size="36" name="cellulare" maxlength="30"></td>
      </tr>
      <tr>
        <td valign="middle"><span class="Stile29">[i]Sito Internet:[/i]</span></td>
        <td><input type="text" size="36" name="sito" maxlength="30"></td>
      </tr>
      <tr>
        <td valign="middle"><span class="Stile29">Email:</span></td>
        <td><input type="text" size="36" name="email" maxlength="30"></td>
      </tr>
      <tr>
        <td valign="middle"><span class="Stile29">Socio:</span></td>
        <td valign="top"><input name="socio" type="text" value="S&igrave; / No" size="10" maxlength="30">

          [i]Inserire l'opzione corrispondente [/i]</td>
      </tr>
      <tr>
        (.........testo.........)
        </tr>
      <tr>
        <td valign="middle"><span class="Stile29">[i]N&deg; accompagnatori:[/i]</span></td>
        <td><input type="text" size="10" name="accompagnatori" maxlength="2">
          [b]&euro; 20,00[/b] [i](a persona)[/i]</td>
      </tr>
      <tr>
        <td><span class="Stile29">[i]Nominativi:[/i]</span></td>
        <td><textarea rows="7" cols="27" name="messaggio1"></textarea></td>
      </tr>
      <tr>
        <td colspan="2" valign="middle">

          &Egrave;  prevista la cena sociale per venerd&igrave; al costo di [b]&euro; 35,00 [/b][i](a persona compreso  l&rsquo;iscritto)[/i]</td>
      </tr>
      <tr>
        <td valign="middle"><span class="Stile29">[i]N&deg; partecipanti:[/i]</span></td>
        <td><input name="partecipanti" type="text" id="partecipanti" size="10" maxlength="2"></td>
      </tr>
      <tr>
        <td><span class="Stile29">[i]Nominativi:[/i]</span></td>
        <td><textarea name="messaggio2" cols="27" rows="7" id="messaggio2"></textarea></td>
      </tr>
      <tr>
      <td></td>
      <td> <input type="button" value="Invia" onClick="Modulo()"> <input type="reset" value="Reset">    </td>
      </tr>
    </table>
     </form>
    </body>

    </html> 
    mailto.php
    Codice PHP:
    <?php
    //varie info per email
    $oggi date("j F Y G:i");
    $sito "http://www.cstudifoligno.it";
    $ip "$_SERVER[REMOTE_ADDR]";
    $browser "$_SERVER[HTTP_USER_AGENT]";
    $to "altheovalentini@hotmail.com";
    $soggetto "ISCRIZIONE AL 4° CONGRESSO NAZIONALE CIVES";

    if(
    trim($_POST['nome']) == "" OR trim($_POST['cognome']) == "" OR trim($_POST['cf']) == "" OR trim($_POST['ente']) == "" OR trim($_POST['ruolo']) == "" OR trim($_POST['professione']) == "" OR trim($_POST['indirizzo']) == "" OR trim($_POST['cap']) == "" OR trim($_POST['citta']) == "" OR trim($_POST['provincia']) == "" OR trim($_POST['telefono']) == "" OR trim($_POST['email']) == "" OR trim($_POST['socio']) == "") {
    echo 
    "<font color=\"#FF0000\" face=\"verdana\" size=\"2\">[b]Tutti i campi sono obbligatori[/b]</font>";

    } else {

    $body "Modulo inviato il $oggi da $ip - $browser \n\n";
    $body .= "Nome: $_POST[nome] \nCognome: $_POST[cognome] \nC.F.: $_POST[cf] \nEnte/Azienda: $_POST[ente] \nRuolo: $_POST[ruolo] \nProfessione: $_POST[professione] \nIndirizzo: $_POST[indirizzo] \nCAP: $_POST[cap] \nCittà: $_POST[citta] \nProvincia: $_POST[provincia] \nTelefono: $_POST[telefono] \nFax: $_POST[fax] \nCellulare: $_POST[cellulare] \nSito Internet: $_POST[sito] \nEmail: $_POST[email] \nSocio: $_POST[socio] \nN° accompagnatori: $_POST[accompagnatori] \nNominativi: $_POST[messaggio1] \nN° Partecipanti: $_POST[partecipanti] \nNominativi: $_POST[messaggio2]";

    mail("$to","$soggetto","$body");
    ?>
    <html>
    <head>
    <meta http-equiv="Content-Language" content="it">
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Centro Studi Città di Foligno</title>
    <LINK REL="stylesheet" TYPE="text/css" HREF="style.css">
    <style type="text/css">
    <!--
    .Stile5 {font-size: 10px}
    -->
    </style>
    </head>

    <body>
    (.........)
    </body>

    </html>
    <?php
    }
    ?>

    sapete dirmi dov'è l'errore?

    Grazie a tutti in anticipo!

  2. #2
    risolto grazie!

    era tutto ok ma il dominio su cui caricavo lo script aveva delle protezioni particolari!

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 © 2024 vBulletin Solutions, Inc. All rights reserved.