Questo è un form che ho creato con le date di arrivo e partenza:
<form name="differenza_date" method="post" action="preventivo.php">
<table>
<tr>
<td>inserire data iniziale:</td>
<td>
<select name="giornoinizio">
<option>giorno</option>
<option value="1" > 1 </option>
<option value="2" > 2 </option>
<option value="3" > 3 </option>
<option value="4" > 4 </option>
<option value="5" > 5 </option>
<option value="6" > 6 </option>
<option value="7" selected="selected"> 7 </option>
<option value="8" > 8 </option>
<option value="9" > 9 </option>
<option value="10" > 10 </option>
<option value="11" > 11 </option>
<option value="12" > 12 </option>
<option value="13" > 13 </option>
<option value="14" > 14 </option>
<option value="15" > 15 </option>
<option value="16" > 16 </option>
<option value="17" > 17 </option>
<option value="18" > 18 </option>
<option value="19" > 19 </option>
<option value="20" > 20 </option>
<option value="21" > 21 </option>
<option value="22" > 22 </option>
<option value="23" > 23 </option>
<option value="24" > 24 </option>
<option value="25" > 25 </option>
<option value="26" > 26 </option>
<option value="27" > 27 </option>
<option value="28" > 28 </option>
<option value="29" > 29 </option>
<option value="30" > 30 </option>
<option value="31" > 31 </option>
</select>
</td><td>
<select name="meseinizio">
<option>mese</option>
<option value="1" selected="selected">Gennaio</option>
<option value="2" >Febbraio</option>
<option value="3" >Marzo</option>
<option value="4" >Aprile</option>
<option value="5" >Maggio</option>
<option value="6" >Giugno</option>
<option value="7" >Luglio</option>
<option value="8" >Agosto</option>
<option value="9" >Settembre</option>
<option value="10" >Ottobre</option>
<option value="11" >Novembre</option>
<option value="12" >Dicembre</option>
</select>
</td><td>
<select name="annoinizio">
<option>Anno</option>
<option value="2013" > 2013 </option>
<option value="2014" selected="selected"> 2014 </option>
<option value="2015" > 2015 </option>
<option value="2016" > 2016 </option>
<option value="2017" > 2017 </option>
<option value="2018" > 2018 </option>
<option value="2019" > 2019 </option>
<option value="2020" > 2020 </option>
<option value="2021" > 2021 </option>
<option value="2022" > 2022 </option>
<option value="2023" > 2023 </option>
<option value="2024" > 2024 </option>
<option value="2025" > 2025 </option>
<option value="2026" > 2026 </option>
<option value="2027" > 2027 </option>
<option value="2028" > 2028 </option>
<option value="2029" > 2029 </option>
<option value="2030" > 2030 </option>
<option value="2031" > 2031 </option>
<option value="2032" > 2032 </option>
<option value="2033" > 2033 </option>
<option value="2034" > 2034 </option>
<option value="2035" > 2035 </option>
<option value="2036" > 2036 </option>
<option value="2037" > 2037 </option>
<option value="2038" > 2038 </option>
<option value="2039" > 2039 </option>
<option value="2040" > 2040 </option>
<option value="2041" > 2041 </option>
<option value="2042" > 2042 </option>
<option value="2043" > 2043 </option>
</select>
</td>
</tr><tr>
<td>inserire data finale:</td>
<td>
<select name="giornofine">
<option>giorno</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
<option value="8">8</option>
<option value="9">9</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
<option value="13">13</option>
<option value="14">14</option>
<option value="15">15</option>
<option value="16">16</option>
<option value="17">17</option>
<option value="18">18</option>
<option value="19">19</option>
<option value="20">20</option>
<option value="21">21</option>
<option value="22">22</option>
<option value="23">23</option>
<option value="24">24</option>
<option value="25">25</option>
<option value="26">26</option>
<option value="27">27</option>
<option value="28">28</option>
<option value="29">29</option>
<option value="30">30</option>
<option value="31">31</option>
</select>
</td><td>
<select name="mesefine">
<option>mese</option>
<option value="1">Gennaio</option>
<option value="2">Febbraio</option>
<option value="3">Marzo</option>
<option value="4">Aprile</option>
<option value="5">Maggio</option>
<option value="6">Giugno</option>
<option value="7">Luglio</option>
<option value="8">Agosto</option>
<option value="9">Settembre</option>
<option value="10">Ottobre</option>
<option value="11">Novembre</option>
<option value="12">Dicembre</option>
</select>
</td><td>
<select name="annofine">
<option>Anno</option>
<option value="2013">2013</option>
<option value="2014">2014</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
<option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
<option value="2023">2023</option>
<option value="2024">2024</option>
<option value="2025">2025</option>
<option value="2026">2026</option>
<option value="2027">2027</option>
<option value="2028">2028</option>
<option value="2029">2029</option>
<option value="2030">2030</option>
<option value="2031">2031</option>
<option value="2032">2032</option>
<option value="2033">2033</option>
<option value="2034">2034</option>
<option value="2035">2035</option>
<option value="2036">2036</option>
<option value="2037">2037</option>
<option value="2038">2038</option>
<option value="2039">2039</option>
<option value="2040">2040</option>
<option value="2041">2041</option>
<option value="2042">2042</option>
<option value="2043">2043</option>
</select>
</td>
</tr><tr>
<td><input type="submit" name="differenza_date" value="Calcola differenza tra date" style="padding:0 1px;" /></td>
</tr>
</table>
</form>
Gli ho detto di passare i dati al file preventivo.php, che riporto sotto. Qui sto lavorando per inviarmi le date via email per vedere il formato di arrivo, ma se riesci a moficicare direttamente questo codice per far uscire il risultato a video va benissimo !!
<?PHP
// Processo di recupero dei dati
$giornoinizio = $_POST['giornoinizio'];
$meseinizio = $_POST['meseinizio'];
$annoinizio = $_POST['annoinizio'];
$giornofine = $_POST['giornofine'];
$mesefine = $_POST['mesefine'];
$annofine = $_POST['annofine'];
// [Destinatario, mittente, ecc]
$mail_to = "
[email protected]";
$mail_subject = "Prova preventivo";
// Intestazioni HTML
$mail_in_html = "MIME-Version: 1.0\r\n";
$mail_in_html .= "Content-type: text/html; charset=utf-8\r\n";
$mail_in_html .= "From: <$mail_from>";
// Processo di invio
if (mail($mail_to, $mail_subject, $mail_body, $mail_in_html))
{
print "Messaggio inviato con successo!";
}
else
{
print "Errore";
// le parentesi devono essere tante quante il numero dei campi inseriti all'inizio
}
?>