[PHP] strano problema con un form

In questo Forum potrete chiedere consigli (ma anche condividere le vostre conoscenze) sulla progettazione e realizzazione di siti. Scoprite con le nostre Muse i segreti del web design... e perché nessuno va a vedere quella paginetta che vi è costata tanta fatica. Html, xhtml, xml, css, php, asp, js, flash e tutto quel che ci gira attorno.

Moderatori: Supervisor, Moderatori Software e Programmazione

Avatar utente
Nik
Semidio
Semidio
Messaggi: 204
Iscritto il: 29 ott 2005 17:44

[PHP] strano problema con un form

Messaggio da Nik »

Devo realizzare (urgentemente!) un semplice form per la raccolta e l'invio di alcuni dati.

Fatto il form (in html), a posto il css... per il file php che deve eseguire l'invio prendo il codice di un altro script che avevo già usato più volte con successo...

completato il tutto, vado a provare e.... il modulo viene inviato... MA I DATI INSERITI NELLA FORM NON PASSANO! #-o

ho provato con il codice di un altro script... stesso discorso... ho pensato fosse un problema di server... quindi ho provato su un altro server... stessa pappa ](*,)

non so più che pesci prendere :?

incollo il codice e ditemi se c'è qualcosa che non va

Codice: Seleziona tutto

<?php
$to = "info@xxxxxx.it";
$headers = "From: " . $_POST['mail'] . "\n";
// soggetto della mail
$subject = "Modulo dati xxxx";

// corpo messaggio
$body = "Contenuto del modulo:\n\n";

$body .= "Inviata da: " . trim(stripslashes($_POST["mail"])) . "\n"; //indirizzo e-mail mittente

$body .= "Cognome: " . trim(stripslashes($_POST["cognome"])) . "\n"; //cognome
$body .= "Nome: " . trim(stripslashes($_POST["nome"])) . "\n"; //nome
$body .= "Codice Fiscale: " . trim(stripslashes($_POST["codfisc"])) . "\n"; //C.F.
$body .= "Num. cellulare: " . trim(stripslashes($_POST["cell"])) . "\n"; //tel
$body .= "e-Mail: " . trim(stripslashes($_POST["mail"])) . "\n"; //email

$body .= "Targa: " . trim(stripslashes($_POST["targa"])) . "\n"; //targa
$body .= "Tipo veicolo: " . trim(stripslashes($_POST["veicolo"])) . "\n"; //tipo
$body .= "Massa complessiva: " . trim(stripslashes($_POST["massa"])) . "\n"; //massa
$body .= "Cilindrata veicolo: " . trim(stripslashes($_POST["cilindrata"])) . "\n"; //cilindrata

// invio mail
if (mail($to, $subject, $body, $headers)) // SE L'INOLTRO E' ANDATO A BUON FINE...
{
 echo "I dati sono stati inviati con successo. Grazie.";
} else {// altrimenti
 echo "Deve compilare la form prima di inviare.";
}
?>


e il form

Codice: Seleziona tutto

<form action="invio.php" method="post" enctype="text/plain">
<fieldset class="maschera">
<legend>Raccolta dati per xxxxxxxxxxxxxxxxxxxxxx</legend>
<center>
<h3><strong>TITOLO</strong></h3>
</center>
<p class="form">
<strong>Data decorrenza associazione: (gg/mm/aaaa)</strong> <input name="data" type="text" maxlength="10" size="10" />
<h3>Beneficiario Tessera</h3>
 <table>
  <tr>
    <td width="50%" valign="top"><strong>COGNOME</strong>: </td>
    <td width="50%" valign="top"><input name="cognome" type="text" maxlength="50" /></td>
  </tr>
  <tr>
    <td width="50%" valign="top"><strong>NOME</strong>: </td>
    <td width="50%" valign="top"><input name="nome" type="text" maxlength="50" /></td>
  </tr>
  <tr>
    <td width="50%" valign="top"><strong>CODICE FISCALE</strong>: </td>
    <td width="50%" valign="top"><input name="codfisc" type="text" maxlength="16" size="18" /></td>
  </tr>
  <tr>
    <td width="50%" valign="top"><strong>CELLULARE</strong>: </td>
    <td width="50%" valign="top"><input name="cell" type="text" maxlength="10" size="10" /></td>
  </tr>
  <tr>
    <td width="50%" valign="top"><strong>E-MAIL</strong>: </td>
    <td width="50%" valign="top"><input name="email" type="text" maxlength="50" /></td>
  </tr>
 </table>
<h3>Dati Veicolo</h3>
 <table>
  <tr>
    <td width="50%" valign="top"><strong>TARGA</strong>: </td>
    <td width="50%" valign="top"><input name="targa" type="text" maxlength="50" /></td>
  </tr>
  <tr>
    <td width="50%" valign="top"><strong>TIPO VEICOLO</strong>: </td>
    <td width="50%" valign="top"><select name="veicolo">  <option selected="selected"> </option>
    <option>Autovettura</option>    <option>Autocarro &lt; 2500 Kg.</option>    <option>Motoveicolo</option></select>    </td>
  </tr>
  <tr>
    <td width="50%" valign="top"><strong>MASSA COMPLESSIVA</strong>: </td>
    <td width="50%" valign="top"><input name="massa" type="text" maxlength="50" /></td>
  </tr>
  <tr>
    <td width="50%" valign="top"><strong>CILINDRATA</strong>: </td>
    <td width="50%" valign="top"><input name="cilindrata" type="text" maxlength="50" /></td>
  </tr>
 </table>
<br />
<input type="submit" value="INVIA" name="invia" />  <input type="reset" value="Cancella" />
</p>
</fieldset>
</form>
Avatar utente
Nik
Semidio
Semidio
Messaggi: 204
Iscritto il: 29 ott 2005 17:44

Messaggio da Nik »

risolto eliminando l'enctype della form! :shock:

Torna a “Linguaggi per Internet”