Visualizzazione risultati 1 fino 4 di 4

Discussione: Errore invio messaggio

  1. #1
    Guest

    Predefinito Errore invio messaggio

    Allora, ho questi 2 codici, ma non funzionano... Sapreste dirmi perchè?? (Io vorrei che compilando quel modulo mi venga inviato un messaggio con la formazione.

    Codice PHP:
    <form name="form1" method="post" action="mail.php">
    <
    table width="95%" align="center" >
    <
    tr> <td colspan="2"><div align="center"><strong>NOME SQUADRA</strong></div></td> </tr> <tr> <td width="16%"><strong>Portiere</strong></td> <td width="84%"><input type="text" name="portiere"></td> </tr> <tr> <td><strong>Difensore</strong></td> <td><input type="text" name="pifensore"></td> </tr> <tr> <td><strong>Citt&agrave; </strong></td> <td><input type="text" name="citta"></td> </tr> <tr> <td><strong>Centrocampista </strong></td> <td><input type="text" name="Centrocampista "></td> </tr> <tr> <td><strong>Attaccante</strong></td> <td><input type="text" name="Attaccante"></td> </tr> <tr> <td><strong>Testo</strong></td> <td><textarea name="testo" cols="40" rows="10"></textarea></td> </tr> <tr> <td colspan="2">&nbsp;</td> </tr> <tr> <td colspan="2"><div align="center"> <input type="submit" name="Submit" value="Invia"> </div></td> </tr> </table> </form>
    Questo è il contatti.php

    Codice PHP:
    <?php // L'INDIRIZZO DEL DESTINATARIO DELLA MAIL $to = "lele.venturi@libero.it"; // IL SOGGETTO DELLA MAIL $subject = "Modulo proveniente dal sito www.sito.it"; // COSTRUZIONE DEL CORPO DEL MESSAGGIO $body = "Contenuto del modulo:\n\n"; $body .= "Dati personali ;<br>Portiere: " . trim(stripslashes($_POST["portiere"])) . "\n"; $body .= "Difensore: " . trim(stripslashes($_POST["difensore"])) . "\n"; $body .= "Città: " . trim(stripslashes($_POST["citta"])) . "\n"; $body .= "Centrocampista: " . trim(stripslashes($_POST["centrocampista"])) . "\n"; $body .= "testo: " . trim(stripslashes($_POST["testo"])) . "\n"; $body .= "attaccante: " . trim(stripslashes($_POST["attaccante"])) . "\n"; // INTESTAZIONI SUPPLEMENTARI $headers = "From: Modulo utenti<lele.venturi@libero.it>"; // INVIO DELLA MAIL if(@mail($to, $subject, $body, $headers)) { // SE L'INOLTRO E' ANDATO A BUON FINE... echo "La mail è stata inoltrata con successo."; } else {// ALTRIMENTI... echo "Si sono verificati dei problemi nell'invio della mail."; } ?>
    E questo il mail.php! Grazie in anticipo!

  2. #2
    L'avatar di miki92
    miki92 non è connesso AlterGuru 2500
    Data registrazione
    21-04-2007
    Residenza
    Procida (NA)
    Messaggi
    4,226

    Predefinito

    Spero che il file mail.php non sia davvero formato così come l'hai scritto...vero?

    Perchè così come sta è tutto un commento e quindi non funziona di sicuro, mentre per funzionare dovrebbe essere così:
    Codice PHP:
    <?php
    // L'INDIRIZZO DEL DESTINATARIO DELLA MAIL
    $to = "lele.venturi@libero.it";
    // IL SOGGETTO DELLA MAIL
    $subject = "Modulo proveniente dal sito www.sito.it";
    // COSTRUZIONE DEL CORPO DEL MESSAGGIO
    $body = "Contenuto del modulo:\n\n"; $body .= "Dati personali ;<br>Portiere: " . trim(stripslashes($_POST["portiere"])) . "\n"; $body .= "Difensore: " . trim(stripslashes($_POST["difensore"])) . "\n"; $body .= "Città: " . trim(stripslashes($_POST["citta"])) . "\n"; $body .= "Centrocampista: " . trim(stripslashes($_POST["centrocampista"])) . "\n"; $body .= "testo: " . trim(stripslashes($_POST["testo"])) . "\n"; $body .= "attaccante: " . trim(stripslashes($_POST["attaccante"])) . "\n";

    // INTESTAZIONI SUPPLEMENTARI
    $headers = "From: Modulo utenti<lele.venturi@libero.it>";
    // INVIO DELLA MAIL
    if(@mail($to, $subject, $body, $headers)) {
    // SE L'INOLTRO E' ANDATO A BUON FINE...
    echo "La mail è stata inoltrata con successo."; } else {
    // ALTRIMENTI...
    echo "Si sono verificati dei problemi nell'invio della mail."; }
    ?>
    Apprezzi l'aiuto? Offrimi un caffè!

  3. #3
    Guest

    Predefinito

    Sisi, scusa, errore mio!

    Posso farti una domanda?
    Se volessi fare in modo da farmi inviare un dato preimpostato nell'oggetto con scritto il nome dell'utente che me lo ha inviato come dovrei fare?

  4. #4
    L'avatar di miki92
    miki92 non è connesso AlterGuru 2500
    Data registrazione
    21-04-2007
    Residenza
    Procida (NA)
    Messaggi
    4,226

    Predefinito

    Basta sostituire:
    Codice PHP:
    $subject = "Modulo proveniente dal sito www.sito.it";
    Con:
    Codice PHP:
    $subject = "Messaggio inviato dall'utente: ".$_POST['nomeutente'];
    Ed aggiungere al tuo codice HTML:
    Codice HTML:
    <tr> <td width="16%"><strong>Nome Utente</strong></td> <td width="84%"><input type="text" name="nomeutente" /></td> </tr> 
    Per esempio in questo modo:
    Codice HTML:
    <form name="form1" method="post" action="mail.php">  
    <table width="95%" align="center" >  
    <tr> <td colspan="2"><div align="center"><strong>NOME SQUADRA</strong></div></td> </tr> 
    <tr> <td width="16%"><strong>Nome Utente</strong></td> <td width="84%"><input type="text" name="nomeutente" /></td> </tr> 
    
    <tr> <td width="16%"><strong>Portiere</strong></td> <td width="84%"><input type="text" name="portiere"></td> </tr> 
    <tr> <td><strong>Difensore</strong></td> <td><input type="text" name="pifensore"></td> </tr>
     <tr> <td><strong>Citt&agrave; </strong></td> <td><input type="text" name="citta"></td> </tr>
      <tr> <td><strong>Centrocampista </strong></td> <td><input type="text" name="Centrocampista "></td> </tr> 
      <tr> <td><strong>Attaccante</strong></td> <td><input type="text" name="Attaccante"></td> </tr>
       <tr> <td><strong>Testo</strong></td> <td><textarea name="testo" cols="40" rows="10"></textarea></td> </tr> 
       <tr> <td colspan="2">&nbsp;</td> </tr> <tr> <td colspan="2"><div align="center"> <input type="submit" name="Submit" value="Invia"> </div></td> </tr> </table> </form>
    Apprezzi l'aiuto? Offrimi un caffè!

Regole di scrittura

  • Non puoi creare nuove discussioni
  • Non puoi rispondere ai messaggi
  • Non puoi inserire allegati.
  • Non puoi modificare i tuoi messaggi
  •