Bonjour à tous,
J’ai un formulaire de contact sur la page d’accueil d’un thème Wordpress qui me génère pas mal de spam.
Pour contrer cela, j’ai ajouté 2 input de type “text” (‘spam’, masqué par CSS) et “hidden” (‘nickname’) et un if pour vérifier que ces 2 champs soient bien tous les 2 vides au submit, ce qui donne :
if (!isset($_POST['spam']) && !isset($_POST['nickname']))
{
mail ($admin_email, $admin_subject, $body, $headers);
}
Mais problème, je reçois quand même des mails alors que le champs “spam” est rempli :
Auriez-vous une idée du problème ?
À toute fin utile, un extrait du code du modèle pour la page d’accueil (index.php) :
<?php
//Contact script created by Tim McDaniels and Darren Hoyt for the Mimbo Pro and Agregado themes
//May be re-used with credits intact
if($_REQUEST['submit']):
?>
<?php
$admin_email = get_settings( "contact_email" );
$admin_subject = get_settings( "contact_subject" );
$admin_success = get_settings( "contact_success" );
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: ' . $admin_email . "\r\n";
$body = "<blockquote>
Name: " . $_REQUEST['Name'] . "<br/>
Email: " . $_REQUEST['Email'] . "<br/>
Spam: " . $_REQUEST['spam'] . "<br/>
Nickname: " . $_REQUEST['nickname'] . "<br/>
Message:<br/>" . $_REQUEST['Message'] . "<br/>
<hr/>
Remote Address: " . $_SERVER['REMOTE_ADDR'] . "<br/>
Browser: " . $_SERVER['HTTP_USER_AGENT'] . "
<hr/>
</blockquote>";
if (!isset($_POST['spam']) && !isset($_POST['nickname']))
{
mail ($admin_email, $admin_subject, $body, $headers);
}
?>
<?php endif; ?>
<form onsubmit="return(submitContactForm(this));" id="contactform" action="">
<h3>Gardez <em>le</em> Contact</h3>
<fieldset>
<legend>Contact</legend>
<label for="user-name">Votre nom</label>
<input type="text" id="spam" name="spam" class="spam" />
<input type="hidden" id="nickname" name="nickname" class="field" />
<input type="text" id="user-name" name="Name" class="field" />
<label for="user-email">Votre Email</label>
<input type="text" id="user-email" name="Email" class="field" />
<label for="user-comment">Votre Message</label>
<textarea id="user-comment" name="Message" class="field" cols="" rows="" ></textarea>
<input type="hidden" name="submit" value="1" />
<input type="submit" value="Envoyer »" id="submit" class="button" />
</fieldset>
</form>
</div><!--END WRAPPER-->
</div><!--END MIDDLE-->
<?php get_footer(); ?>
Merci d’avance pour votre aide
Edité le 15/06/2009 à 12:29