Pagina 1 di 2 1 2 ultimoultimo
Visualizzazione dei risultati da 1 a 10 su 20

Discussione: Form Mail php

  1. #1
    Utente di HTML.it L'avatar di gaten
    Registrato dal
    Jul 2007
    Messaggi
    1,269

    Form Mail php

    Salve ragazzi ho un problema con un form mail in php, allora quando io compilo il modulo e premo invio mi da questo errore...:

    The email was not sent

    Please fill all the required fields

    Ecco il file send.php

    <?php
    $receiverMail = "miaemail@hotmail.it";

    $nome = ltrim(rtrim(strip_tags(stripslashes($_POST['nome']))));
    $cognome = ltrim(rtrim(strip_tags(stripslashes($_POST['cognome']))));
    $email = ltrim(rtrim(strip_tags(stripslashes($_POST['email']))));
    $via = ltrim(rtrim(strip_tags(stripslashes($_POST['via']))));
    $citta = ltrim(rtrim(strip_tags(stripslashes($_POST['citta']))));
    $provincia = ltrim(rtrim(strip_tags(stripslashes($_POST['provincia']))));
    $telefono = ltrim(rtrim(strip_tags($_POST['telefono'])));
    $fax = ltrim(rtrim(strip_tags($_POST['fax'])));
    $msg = ltrim(rtrim(strip_tags($_POST['messaggio'])));

    $ip = getenv("REMOTE_ADDR");
    $msgformat = "From: $nome ($ip)\nEmail: $email\n\n$messaggio";

    // VALIDATION
    if(empty($nome) || empty($cognome) || empty($email) || empty($via) || empty($citta) || empty($provincia) || empty($telefono) || empty($fax) || empty($messaggio)) {
    echo "<h3>The email was not sent</h3>

    Please fill all the required fields</p>";
    }
    elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
    echo "<h3>The email was not sent</h3>

    The email address is invalid</p>";
    }
    else {
    mail($receiverMail, $nome, $msgformat, "From: $nome <$email>");
    echo "<h3>The email has been sent!</h3>

    I will get back to you as soon as possible.</p>"; }
    ?>


    Potete fare una prova qui...

    http://www.provasite.altervista.org/.../contatti.html

    Grazie
    Con i sogni possiamo conoscere il futuro...

  2. #2
    intanto usa la funzione trim() invece di farlo una volta a lato
    poi ti da sempre quello perchè la variabile $messaggio non la crei ma crei la variabile $msg

    ciau

  3. #3
    Utente di HTML.it L'avatar di gaten
    Registrato dal
    Jul 2007
    Messaggi
    1,269
    Bè ho corretto questa cosa ma lo stesso non mi funziona e mi da sempre quell errore
    Con i sogni possiamo conoscere il futuro...

  4. #4
    hai corretto anche

    Codice PHP:
    $messaggio in $msg 
    posta il codice corretto che hai

  5. #5
    Utente di HTML.it L'avatar di gaten
    Registrato dal
    Jul 2007
    Messaggi
    1,269
    <?php
    $receiverMail = "gatenweb@yahoo.it";

    $nome = ltrim(rtrim(strip_tags(stripslashes($_POST['nome']))));
    $cognome = ltrim(rtrim(strip_tags(stripslashes($_POST['cognome']))));
    $email = ltrim(rtrim(strip_tags(stripslashes($_POST['email']))));
    $via = ltrim(rtrim(strip_tags(stripslashes($_POST['via']))));
    $telefono = ltrim(rtrim(strip_tags(stripslashes($_POST['telefono']))));
    $fax = ltrim(rtrim(strip_tags(stripslashes($_POST['fax']))));
    $citta = ltrim(rtrim(strip_tags(stripslashes($_POST['citta']))));
    $provincia = ltrim(rtrim(strip_tags(stripslashes($_POST['provincia']))));
    $messaggio = ltrim(rtrim(strip_tags($_POST['messaggio'])));

    $ip = getenv("REMOTE_ADDR");
    $msgformat = "From: $name ($ip)\nEmail: $email\n\n$messaggio";

    // Validation
    if(empty($nome) || empty($cognome) || empty($email) || empty($via)|| empty($telefono) || empty($fax) || empty($citta)|| empty($provincia) || empty($messaggio)) {
    echo "<h3>The email was not sent</h3>

    Please fill all the required fields</p>";
    }
    elseif(!ereg("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) {
    echo "<h3>The email was not sent</h3>

    The email address is invalid</p>";
    }
    else {
    mail($receiverMail, $email, $msgformat, "From: $nome <$email>");
    echo "<h3>The email has been sent!</h3>

    I will get back to you as soon as possible.</p>"; }
    ?>
    Con i sogni possiamo conoscere il futuro...

  6. #6
    Utente di HTML.it L'avatar di gaten
    Registrato dal
    Jul 2007
    Messaggi
    1,269
    Scusate potrebbe essere un errore nel form dell'html?
    Con i sogni possiamo conoscere il futuro...

  7. #7
    Utente di HTML.it L'avatar di gaten
    Registrato dal
    Jul 2007
    Messaggi
    1,269
    Ecco l'html:

    <td width="158" height="25" class="Stile8 Stile15 Stile16">* Nome:</td>
    <td width="165" class="Stile8 Stile15 Stile16">* Cognome:</td>
    </tr>
    <tr>
    <td><input name="nome" type="text" class="campi" id="nome" /></td>
    <td><input name="cognome" type="text" class="campi" id="cognome" /></td>
    </tr>
    <tr>
    <td height="25" class="Stile8 Stile15 Stile16">* Via:</td>
    <td height="20"></td>
    </tr>
    <tr>
    <td colspan="2"><input name="via" type="text" class="campi" id="via" size="47" /></td>
    </tr>
    <tr>
    <td height="25" class="Stile8 Stile15 Stile16">* Citt&agrave;:</td>
    <td class="Stile8 Stile15 Stile16">* Provincia:</td>
    </tr>
    <tr>
    <td><input name="citta" type="text" class="campi" id="citta" /></td>
    <td><input name="provincia" type="text" class="provincia" id="provincia" size="3" maxlength="2" /></td>
    </tr>
    <tr>
    <td height="25" class="Stile8 Stile15 Stile16">* Telefono:</td>
    <td class="Stile8 Stile15 Stile16">Fax:</td>
    </tr>
    <tr>
    <td><input name="telefono" type="text" class="campi" id="telefono" /></td>
    <td><input name="fax" type="text" class="campi" id="fax" /></td>
    </tr>
    <tr>
    <td height="25" class="Stile8 Stile15 Stile16">E-mail:</td>
    <td></td>
    </tr>
    <tr>
    <td colspan="2"><input name="email" type="text" class="campi" id="email" size="47" /></td>
    </tr>
    <tr>
    <td height="25" class="Stile8 Stile15 Stile16">* Messaggio:</td>
    <td></td>
    </tr>
    <tr>
    <td height="21" colspan="2"><form id="form2" name="form2" method="post" action="">
    <label>
    <textarea name="messaggio" class="messaggio" cols="35" rows="8" id="messaggio"></textarea>
    </label>
    </form>
    </td>
    </tr>
    <tr>
    <td height="41" colspan="2" valign="bottom"><form id="form1" name="form1" method="post" action="contact_form.php">
    <label>
    <input name="Submit" type="submit" class="invia" value="Invia" />
    </label>
    </form>


    In basso come vedi c'è il form per collegarlo al file contact_form.php
    Con i sogni possiamo conoscere il futuro...

  8. #8
    appunto ci sarei arrivato successivamente
    ed in effetti l'errore è li
    perchè tu tutti i campi li lasci fuori dal form1 che è quello che invia i dati a contact_form.php

    quindi inserisci tutti i campi dentro e vedi se va

  9. #9
    Utente di HTML.it L'avatar di gaten
    Registrato dal
    Jul 2007
    Messaggi
    1,269
    Dentro ? scusami ma non ho capito magari mi faresti un esempio sul codice che ho postato? sinceramente io ho inserito i capit ecc ecc... e mi ha fatto tutto automaticamente ... specifico che utilizzo Dreamwaver...
    Con i sogni possiamo conoscere il futuro...

  10. #10
    Codice PHP:
    <tr>
    <
    form id="form1" name="form1" method="post" action="contact_form.php">
    <
    td width="158" height="25" class="Stile8 Stile15 Stile16">* Nome:</td>
    <
    td width="165" class="Stile8 Stile15 Stile16">* Cognome:</td>
    </
    tr>
    <
    tr>
    <
    td><input name="nome" type="text" class="campi" id="nome" /></td>
    <
    td><input name="cognome" type="text" class="campi" id="cognome" /></td>
    </
    tr>
    <
    tr>
    <
    td height="25" class="Stile8 Stile15 Stile16">* Via:</td>
    <
    td height="20"> </td>
    </
    tr>
    <
    tr>
    <
    td colspan="2"><input name="via" type="text" class="campi" id="via" size="47" /></td>
    </
    tr>
    <
    tr>
    <
    td height="25" class="Stile8 Stile15 Stile16">* Città:</td>
    <
    td class="Stile8 Stile15 Stile16">* Provincia:</td>
    </
    tr>
    <
    tr>
    <
    td><input name="citta" type="text" class="campi" id="citta" /></td>
    <
    td><input name="provincia" type="text" class="provincia" id="provincia" size="3" maxlength="2" /></td>
    </
    tr>
    <
    tr>
    <
    td height="25" class="Stile8 Stile15 Stile16">* Telefono:</td>
    <
    td class="Stile8 Stile15 Stile16">Fax:</td>
    </
    tr>
    <
    tr>
    <
    td><input name="telefono" type="text" class="campi" id="telefono" /></td>
    <
    td><input name="fax" type="text" class="campi" id="fax" /></td>
    </
    tr>
    <
    tr>
    <
    td height="25" class="Stile8 Stile15 Stile16">E-mail:</td>
    <
    td> </td>
    </
    tr>
    <
    tr>
    <
    td colspan="2"><input name="email" type="text" class="campi" id="email" size="47" /></td>
    </
    tr>
    <
    tr>
    <
    td height="25" class="Stile8 Stile15 Stile16">* Messaggio:</td>
    <
    td> </td>
    </
    tr>
    <
    tr>
    <
    td height="21" colspan="2">
    <
    label>
    <
    textarea name="messaggio" class="messaggio" cols="35" rows="8" id="messaggio"></textarea>
    </
    label>
    </
    form>
    </
    td>
    </
    tr>
    <
    tr>
    <
    td height="41" colspan="2" valign="bottom">
    <
    label>
    <
    input name="Submit" type="submit" class="invia" value="Invia" />
    </
    label>
    </
    form
    Questa volta, più che un voto.. è favoreggiamento.

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.