<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Problema Checkbox Privacy Contact form - Aiuto!!]]></title><description><![CDATA[<p dir="auto">Salve a tutti, vi espongo il mio problema e sono certo che riuscirete a darmi una mano,<br />
allora, ho il seguente contact form, tutto funziona benissimo solo che ho voluto implementare il checkbox per la privacy.<br />
adesso il problema è che il checkbox non mi manda i dati nella mail, praticamente quando mi arriva la mail tutti i dati arrivano correttamente, nome, email, testo ecc.. ma vorrei che il checkbox mi mandasse il valore "accetto" se spuntato, in caso contrario "non accetto".<br />
ho provato ad implementare nel file php vari codici per il checkbox ma purtroppo non sono riuscito a far funzionare niente, praticamente sto impazzendo da giorni, aiutatemi per favore, consigliatemi il codice da aggiungere per poter ricevere i valori del checkbox.<br />
vi ringrazio in anticipo</p>
<p dir="auto">qui il codice html</p>
<pre><code class="language-html">&lt;form id="contact-form" method="post" action="process.php"&gt;                            
&lt;div class="form-div-1 element"&gt;                                
&lt;label&gt;                                
&lt;input type="text" placeholder="Nome: *(obbligatorio)" name="name" class="text" /&gt;&lt;/label&gt;                            
&lt;/div&gt;                            
&lt;div class="form-div-2 element"&gt;                                
&lt;label&gt;                                
&lt;input type="text" placeholder="Email: *(obbligatorio)" name="email" class="text" /&gt;&lt;/label&gt;                            
&lt;/div&gt;                            
&lt;div class="form-div-3 element"&gt;                                
&lt;label&gt;                                
input type="text" placeholder="Telefono:" name="website" class="text" /&gt;&lt;/label&gt;                            
&lt;/div&gt;                                                        
&lt;div class="element1"&gt;                                
&lt;label class="message"&gt;                                
&lt;textarea name="comment" placeholder="Messaggio: *(obbligatorio)" class="text textarea" /&gt;&lt;/textarea&gt;
&lt;/label&gt;                            
&lt;/div&gt;                            
&lt;div class="form-div-1 element"&gt;                            
&lt;label&gt;                            
&lt;input type="checkbox" id="privacy" name="privacy" value="si" /&gt;                             
&lt;/label&gt;
&lt;p&gt;Accetto &lt;a href="#" title="leggi la nostra informativa" class="informativa_link"&gt;l'informativa sulla privacy&lt;/a&gt;&lt;br /&gt;&lt;/p&gt;                            
&lt;/div&gt;                                                        
&lt;div class="element"&gt;                                                                
&lt;input type="submit" value="CONTATTACI" id="submit"/&gt;                                                            
&lt;/div&gt;                            
&lt;/form&gt;
</code></pre>
<p dir="auto">il codice javascript</p>
<pre><code class="language-html">&lt;script type="text/javascript"&gt;$(document).ready(function() {  
     
//if submit button is clicked    
$('#submit').click(function () { 

//Get the data from all the fields        
var name = $('input[name=name]');        
var email = $('input[name=email]');        
var website = $('input[name=website]');        
var comment = $('textarea[name=comment]');        
var privacy = $('input[name=privacy]');

//Simple validation to make sure user entered something        
//If error found, add hightlight class to the text field        
if (name.val()=='') {            
name.addClass('hightlight');            
return false;        
} else name.removeClass('hightlight');                

if (email.val()=='') {            
email.addClass('hightlight');            
return false;        
} else email.removeClass('hightlight');                

if (comment.val()=='') {            
comment.addClass('hightlight');            
return false;        
} else comment.removeClass('hightlight');                

//organize the data properly        
var data = 'name=' + name.val() + '&amp;email=' + email.val() + '&amp;website=' +         website.val() + '&amp;comment='  + encodeURIComponent(comment.val());                

//disabled all the text fields        
$('.text').attr('disabled','true');                

//show the loading sign        
$('.loading').show();                

//start the ajax        
$.ajax({            
//this is the php file that processes the data and send mail            
url: "process.php",                            
//GET method is used            
type: "GET",
//pass the data                        
data: data,                                
//Do not cache the page            
cache: false,                        
//success            
success: function (html) {                                
//if process.php returned 1/true (send mail success)                
if (html==1) {                                        
//hide the form                    
$('.form').fadeOut('slow');                                                            
//show the success message                    
$('.done').fadeIn('slow');          
                          
//if process.php returned 0/false (send mail failed)                
} else alert('Sorry, unexpected error. Please try again later.');                            
}                
});                

//cancel the submit button default behaviours        
return false;    
});    
});    
&lt;/script&gt;
</code></pre>
<p dir="auto">Adesso di seguito invece il file process.php</p>
<pre><code class="language-php">&lt;?php
//Retrieve form data. 
//GET - user submitted data using AJAX//POST - in case user does not support javascript, we'll use POST instead
$name = ($_GET['name']) ? $_GET['name'] : $_POST['name'];
$email = ($_GET['email']) ?$_GET['email'] : $_POST['email'];
$website = ($_GET['website']) ?$_GET['website'] : $_POST['website'];
$comment = ($_GET['comment']) ?$_GET['comment'] : $_POST['comment'];
if (!empty($_POST['privacy'])) {
$privacy="accetto";
}
else{
$privacy="non accetto";
}  
//flag to indicate which method it uses. If POST set it to 1
if ($_POST) $post=1;
//Simple server side validation for POST data, of course, you should validate the email
if (!$name) $errors[count($errors)] = '(obbligatorio) Inserisci il tuo Nome.';
if (!$email) $errors[count($errors)] = '(obbligatorio) Inserisci la tua Email.'; 
if (!$comment) $errors[count($errors)] = '(obbligatorio) Scrivi un Messaggio.'; 
//if the errors array is empty, send the mailif (!$errors) {
//recipient
$to = 'Your Name &lt;miamail@miamail.com&gt;';    
//sender
$from = $name . ' &lt;' . $email . '&gt;';    
//subject and the html message
$subject = 'Contact form - Messaggio da ' . 
$name;          
$message = ' 

&lt;head&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;table&gt;
&lt;tr&gt;&lt;td&gt;Name&lt;/td&gt;&lt;td&gt;' . $name . '&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Email&lt;/td&gt;&lt;td&gt;' . $email . '&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Website&lt;/td&gt;&lt;td&gt;' . $website . '&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Privacy&lt;/td&gt;&lt;td&gt;' .$privacy. '&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;Comment&lt;/td&gt;&lt;td&gt;' . nl2br($comment) . '&lt;/td&gt;&lt;/tr&gt;        
&lt;/table&gt;
&lt;/body&gt;
&lt;/html&gt;';
//send the mail
$result = sendmail($to, $subject, $message, $from);    

//if POST was used, display the message straight away
if ($_POST) {
if ($result) echo 'Messaggio Inviato! Risponderemo al più presto. Grazie.';else echo 'Spiecenti, Si è verificato un errore. Riprova più tardi.';       
//else if GET was used, return the boolean value so that 
//ajax script can react accordingly
//1 means success, 0 means failed} 
else 
{echo $result;    
}

//if the errors array has values} 
else {
//display the errors message
for ($i=0; $i&lt;count($errors); $i++) echo $errors[$i] . '&lt;br/&gt;';
echo '&lt;a href="form.php"&gt;Back&lt;/a&gt;';
exit;}

//Simple mail function with HTML headerfunction sendmail ($to, $subject, $message, $from {
$headers = "MIME-Version: 1.0" . "\r\n";
$headers .= "Content-type:text/html;charset=iso-8859-1" . "\r\n";
$headers .= 'From: ' . $from . "\r\n";    

$result = mail($to,$subject,$message,$headers);    

if ($result) return 1;
else return 0;}
?&gt;
</code></pre>
]]></description><link>https://dev.connect.gt/topic/203084/problema-checkbox-privacy-contact-form-aiuto</link><generator>RSS for Node</generator><lastBuildDate>Fri, 27 Nov 2026 10:02:54 GMT</lastBuildDate><atom:link href="https://dev.connect.gt/topic/203084.rss" rel="self" type="application/rss+xml"/><pubDate>Tue, 10 Jun 2014 08:25:02 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Problema Checkbox Privacy Contact form - Aiuto!! on Sat, 21 Jun 2014 06:29:46 GMT]]></title><description><![CDATA[<p dir="auto">A parte che vedo errori nel php di parentesi graffe non aperte o non chiuse, puoi provare così:</p>
<pre><code class="language-php">if (isset($_POST['privacy'])) {
       $privacy = "accetto";
   } else { 
       $privacy = "non accetto";
 }
</code></pre>
<p dir="auto">Ciao.</p>
]]></description><link>https://dev.connect.gt/post/1164194</link><guid isPermaLink="true">https://dev.connect.gt/post/1164194</guid><dc:creator><![CDATA[oslino]]></dc:creator><pubDate>Sat, 21 Jun 2014 06:29:46 GMT</pubDate></item><item><title><![CDATA[Reply to Problema Checkbox Privacy Contact form - Aiuto!! on Fri, 13 Jun 2014 11:04:51 GMT]]></title><description><![CDATA[<p dir="auto">Nessuno che mi può aiutare? <img src="https://dev.connect.gt/assets/plugins/nodebb-plugin-emoji/emoji/android/1f61e.png?v=12b9555a9a1" class="not-responsive emoji emoji-android emoji--disappointed" style="height:1.4em;width:auto;vertical-align:middle" title=":(" alt="😞" /></p>
]]></description><link>https://dev.connect.gt/post/1164202</link><guid isPermaLink="true">https://dev.connect.gt/post/1164202</guid><dc:creator><![CDATA[giuspin87]]></dc:creator><pubDate>Fri, 13 Jun 2014 11:04:51 GMT</pubDate></item></channel></rss>