Ciao a tutti,
vi incollo questo form html e relativa pagina in php. Vi spiego, il form funziona, i messaggi arrivano ma quando clicco su invia messaggio non mi va sulla pagina che ho creato contatti.php e non mi da nessun messaggio di conferma di invio. E' un modulo che uso sempre ma stavolta non funziona. Sapete dirmi come mai? Ripeto, i messaggi arrivano ma non mi va nella pagina dei contatti.php, grazie mille!!!!!!

IL FORM NELLA PAGINA HTML:

<form id="contact-form" method="post" action="contatti.php" role="form" class="php-email-form mt-4">
<div class="form-row">
<div class="col-md-6 form-group">
<input type="name" name="name" class="form-control" id="name" placeholder="Nome e cognome *" data-rule="minlen:4" data-msg="Please enter at least 4 chars" required="required" data-error="Firstname is required." />
<div class="validate"></div>
</div>
<div class="col-md-6 form-group">
<input type="email" class="form-control" name="email" id="email" placeholder="Email *" data-rule="email" data-msg="Please enter a valid email" required="required" data-error="Email is required."/>
<div class="validate"></div>
</div>
</div>
<div class="form-row">
<div class="col-md-6 form-group">
<input type="Tel" name="phone" class="form-control" id="form_phone" placeholder="Telefono *" data-rule="minlen:4" data-msg="Please enter a valid number" required="required" data-error="Phone is required."/>
<div class="validate"></div>
</div>
<div class="col-md-6 form-group">
<input type="oggetto" type="oggetto" class="form-control" name="oggetto" id="oggetto" placeholder="Oggetto *" data-rule="minlen:4" data-msg="Please enter a valid message" required="required" data-error="Object is required."/>
<div class="validate"></div>
</div>
</div>
<div class="form-group">
<textarea class="form-control" name="message" rows="5" data-rule="required" data-msg="Please write something for us" placeholder="Scrivi il tuo messaggio *" required="required" data-error="Message is required."></textarea>
<div class="validate"></div>
</div>
<input name="privacy" id="privacy" type="radio" value="si" /> Autorizzo trattamento
<a href="privacy.htm"> Privacy Policy </a><br>
<div class="text-center"><button type="submit">Invia Messaggio</button></div>


</form>

IL CODICE NELLA PAGINA CONTATTI.PHP:


<?php
/*
* CONFIGURE EVERYTHING HERE
*/


// an email address that will be in the From field of the email.
$from = 'Messaggio dal sito di PGW <info@lucabarcaccia.it>';


// an email address that will receive the email with the output of the form
$sendTo = 'Messaggio dal sito PGW <info@lucabarcaccia.it>';


// subject of the email
$subject = 'Messaggio dal sito PGW';


// form field names and their translations.
// array variable name => Text to appear in the email
$fields = array('name' => 'Name', 'email' => 'Email', 'phone' => 'Phone', 'oggetto' => 'Oggetto', 'messaggio' => 'Messaggio', 'privacy' => 'Privacy');


// message that will be displayed when everything is OK
$okMessage = 'Il tuo messaggio è stato inviato correttamente. Grazie!';


// If something goes wrong, we will display this message.
$errorMessage = 'There was an error while submitting the form. Please try again later';


/*
* LET'S DO THE SENDING
*/


// if you are not debugging and don't need error reporting, turn this off by error_reporting(0);
error_reporting(E_ALL & ~E_NOTICE);


if(!$_POST['privacy']){ //Non selezionata
echo 'Attenzione! Non hai accettato la Privacy.';
return;
}
try
{


if(count($_POST) == 0) throw new \Exception('Form is empty');

$emailText = "You have a new message from your contact form\n=============================\n";


foreach ($_POST as $key => $value) {
// If the field exists in the $fields array, include it in the email
if (isset($fields[$key])) {
$emailText .= "$fields[$key]: $value\n";
}
}



// All the neccessary headers for the email.
$headers = array('Content-Type: text/plain; charset="UTF-8";',
'From: ' . $from,
'Reply-To: ' . $from,
'Return-Path: ' . $from,
);

// Send email
mail($sendTo, $subject, $emailText, implode("\n", $headers));


$responseArray = array('type' => 'success', 'message' => $okMessage);
}
catch (\Exception $e)
{
$responseArray = array('type' => 'danger', 'message' => $errorMessage);
}




// if requested by AJAX request return JSON response
if (!empty($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest') {
$encoded = json_encode($responseArray);


header('Content-Type: application/json');


echo $encoded;
}
// else just display the message
else {
echo $responseArray['message'];
}


?>