Rendere il checkbox privacy obbligatorio in questo script!
Per favore, non so come rendere obbligatorio il checkbox privacy in questo script.
Alla mail mi arriva tutto. Ma se una persona non ha barrato la casella di accettazione nel messaggio mi arriva lo stesso " Ho letto e accetato l'informativa privacy". Vorrei far in modo che non possa mandare la mail se non ha barrato il chechbox. Grazie
script html contatti.html
Codice PHP:
<div id="intro">
<div id="intro-in">
<h2>Lascia un messaggio con i tuoi dati e ti contattiamo al più presto noi :</h2>
<p class="intro">
<form name="form1" method="post" action="mail.php">
<table width="95%" align="center" >
<tr>
<td colspan="2"><div align="center"><strong>Garfagnana Servizi</strong></div></td>
</tr>
<tr>
<td width="16%"><strong>Nome</strong></td>
<td width="84%"><input type="text" name="nome"></td>
</tr>
<tr>
<td><strong>Cognome</strong></td>
<td><input type="text" name="cognome"></td>
</tr>
<tr>
<td><strong>Città </strong></td>
<td><input type="text" name="citta"></td>
</tr>
<tr>
<td><strong>Indirizzo E-mail </strong></td>
<td><input type="text" name="mail"></td>
</tr>
<tr>
<td><strong>Oggetto</strong></td>
<td><input type="text" name="oggetto"></td>
</tr>
<tr>
<td><strong>Testo</strong></td>
<td><textarea name="testo" cols="40" rows="10"></textarea></td>
</tr>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td> <input type="checkbox" name="Privacy Accettata" value="privacy" class="required" />
<label for="Privacy Accettata" class="copy">
<a href="infopv.html" target="nw" > Ho letto e accetto l'Informativa sulla Privacy </a>
</label>
</td>
</tr>
<tr>
<td colspan="2"><div align="center">
<input type="submit" name="Submit" value="Invia">
</div></td>
</tr>
</table>
</form>
</p>
</div>
</div>
script php mail.php[/COLOR]
<?php
// L'INDIRIZZO DEL DESTINATARIO DELLA MAIL
$to = "mister_sergione@yahoo.com";
// IL SOGGETTO DELLA MAIL
$subject = "Modulo proveniente dal sito www.gserv.altervista.org";
// COSTRUZIONE DEL CORPO DEL MESSAGGIO
$body = "Contenuto del modulo:\n\n";
$body .= "nome: " . trim(stripslashes($_POST["nome"])) . "\n";
$body .= "cognome: " . trim(stripslashes($_POST["cognome"])) . "\n";
$body .= "Città: " . trim(stripslashes($_POST["citta"])) . "\n";
$body .= "Oggetto: " . trim(stripslashes($_POST["oggetto"])) . "\n";
$body .= "testo: " . trim(stripslashes($_POST["testo"])) . "\n";
$body .= "mail: " . trim(stripslashes($_POST["mail"])) . "\n";
$body .= "Ho letto e accetto l'Informativa sulla Privacy: " . trim(stripslashes($_POST["Privacy Accettata"])) . "\n";
// INTESTAZIONI SUPPLEMENTARI
$headers = "From: Modulo utenti<mister_sergione@yahoo.com>";
// 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.";
}
?>