Salve ragazzi! Sono un niubbo di php è ho questo script che dovrebbe inviare mail d'informazione, avvertire che non si sono completati tutti i campi e porare alla pagina di ringraziamento ... ma la mail non l'invia, non avverte se non si sono completati i campi richiesti e, comunque, porta alla pagina di ringraziamento!
Qualcuno può aiutarmi ?!
Questo è il php
Codice PHP:
<?
// Your email address
$youremail = 'abcd@efg.hi';
// Your web site title (nome del sito)
$websitetitle = 'Titolo';
// Path to "thanks for the message" page
$thankyoupage = 'thankyou.php';
// Send notification to sender (use false if not required)
$sendnotification = true;
#############################################################
// Do not edit below this
#############################################################
$contact_form_action = $_SERVER['PHP_SELF'];
if ((isset($_POST["sendcontact"])) && ($_POST["sendcontact"] == "contactsent")) {
$contacter_form_error = array();
if (empty($_POST['contact_name'])){
$contacter_form_error[] = 'Per favore inserisci Nome e Cognome';
}
if (empty($_POST['contact_email'])){
$contacter_form_error[] = 'Per favore inserisci il tuo indirizzo e-mail';
}
if (empty($_POST['contact_phone'])){
$contacter_form_error[] = 'Per favore inserisci il tuo numero di telefono';
}
if (empty($_POST['contact_comment'])){
$contacter_form_error[] = 'Per favore inserisci il tuo commento/richiesta';
}
else {
$contact_name = stripslashes($_POST['contact_name']);
$contact_email = stripslashes($_POST['contact_email']);
$contact_phone = stripslashes($_POST['contact_phone']);
$contact_comment = $contact_name." Ha rihiesto le seguenti informazioni:\n \"".stripslashes($_POST['contact_comment'])."\"\n";
$subjectline = "$websitetitle | Nuovo messaggio da $contact_name";
if(!empty($_POST['best_time'])) {
$contact_comment .= '(Miglior momento per contattarlo: '.stripslashes($_POST['best_time']).')'."\n";
}
if(!empty($_POST['contact_phone'])) {
$contact_comment .= '(Numero di telefono: '.stripslashes($_POST['contact_phone']).')';
}
mail($youremail, $subjectline, $contact_comment, "From: $contact_email");
if($sendnotification == true) {
$notification_message = "Grazie per averci contattato $contact_name, $websitetitle.";
$notification_subject = "Grazie per aver contattato $websitetitle.";
mail($contact_email, $notification_subject, $notification_message, "From: $youremail");
}
header("Location:$thankyoupage");
}
}
?>
Questo quello inserito nell' html:
Codice PHP:
<?
// Print form field errors if present
if (count($contacter_form_error)>0){
print '<p id="bottom">[b]Compila tutti i campi obbligatori:[/b]</p>'."\n";
print '<ul>'."\n";
foreach($contacter_form_error as $form_err) {
print "<li class=\"error\">$form_err\n";
}
print '[/list]'."\n";
}
?>
<form method="post" id="informazioni_partnership" action="<? print $contact_form_action; ?>">
<div id="informazioni_partnership">
<fieldset>
<h3>Inserisci i tuoi dati</h3>
<label for="contact_name">Nome e Cognome / Azienda <span class="required">*</span></label>
<input type="text" id="contact_name" name="contact_name" size="30" value="<? print $contact_name; ?>" />
<label for="contact_email">Indirizzo E-Mail <span class="required">*</span></label>
<input type="text" id="contact_email" name="contact_email" size="30" value="<? print $contact_email; ?>" />
<label for="contact_phone">Numero di Telefono</label>
<input type="text" id="contact_phone" name="contact_phone" size="30" value="<? print $_POST['contact_phone']; ?>" />
<label for="best_time">Qual'è il momento migliore per contattarti</label>
<select id="best_time" name="best_time">
<option value="">Seleziona</option>
<option value="Morning">Mattino</option>
<option value="Afternoon">Pomeriggio</option>
<option value="Evening">Sera</option>
</select>
<label for="contact_comment">Inserisci le tue richieste: <span class="required">*</span></label>
<textarea name="contact_comment" cols="60" rows="10" id="contact_comment"><? print $contact_comment; ?></textarea>
</fieldset>
<input type="hidden" name="sendcontact" value="contactsent" />
<input type="submit" value="Invia Email" />
Tutti gli spazi obbligatori sono contrassegnati con un asterisco ( <span class="required">*</span> ).</p>
</div>
</form>