Bonjour,
Voila je rencontre un petit problème avec mon code.
Je suis en cours d'apprentissage donc novice...un formulaire me complique la vie je n'arrive pas à faire le lien entre le contenu de mon formulaire et sa validation pour l'envoyer par post et mail. Si quelqu'un veut bien me corriger, merci d'avance.
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans titre</title>
</head>
<body>
<form method="POST" action="verification.php">
<p>
<span class="txterror">Je souhaite adhérer à VO, association 1901, à but non lucratif et d'utilité publique :</span>
<br/><p>
<span class="txtform">Je suis * :</span><br/>
<input checked="checked" class="f1" name="f1" type="radio" value="0" />
<span class="textform"> Particulier : 10€</span>
<input class="f1" name="f1" type="radio" value="1" />
<span class="textform"> Association : 20€</span>
<input class="f1" name="f1" type="radio" value="2" />
<span class="textform"> Société : 40€</span>
<p>
<span class="txtform">Titre * :</span>
<input class="f_2" name="f_2" type="radio" value="0">
<span class="txtform">Mr </span>
<input class="f_2" name="f_2" type="radio" value="1">
<span class="txtform">Mme </span>
<p>
Nom/prénom *:<br />
<input type="text" name="nom" id="nom" placeholder="Votre Nom" />
</p>
Enseigne (sociétés uniquement): <br />
<input name="f_5" size="24" style="width:200; " type="text" value="">
</p>
<p>
Adresse postale * : <br />
<input name="f_6" size="24" style="width:200; " type="text" value="">
<p>
Email *: <br />
<input type="email" name="email" id="email" placeholder="Votre Email" />
</p>
<p>
Sujet *:<br />
<input type="text" name="sujet" id="sujet" placeholder="Quel est votre sujet ?" />
</p>
<p>
Message *:<br />
<textarea id="message" name="message" placeholder="Votre Message" /></textarea>
</p>
<h3>Recopier ce chiffre ?</h3>
<img src="captcha.php" /><br />
<input type="text" name="captcha" style="70px;" /><br />
<p>
Tous les champs avec une * sont obligatoires
<p>
<input type="submit" value="Envoyez" />
</p>
</form>
</body>
</html>
et pour le valider, j'ai fait cela le code est :
<?php
session_start();
if(!empty($_POST['f1']))
{
if($_POST['f1'] == 1)
$f1 = "Particulier";
else
$f1 = "Association";
else
$f1 = "Société"
}
if(!empty($_POST['f_2']))
{
if($_POST['f_2'] == 1)
$f_2 = "Mr";
else
$f_2 = "Mme";
}
$nom = utf8_decode($_POST['nom']);
$f_5 = utf8_decode($_POST['f_5']);
$f_6 = utf8_decode($_POST['f_6']);
$mail = ($_POST['email']);
$subject = utf8_decode($_POST['sujet']);
$message = utf8_decode($_POST['message']);
$headers = 'From: '.$nom.'<'.$mail.'>'."\r\n";
$headers .= 'Reply-to: <'.$mail.'>'."\r\n";
$to = 'wall@hotmail.com';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Document sans titre</title>
</head>
<body>
<?php
if($_POST['captcha']==$_SESSION['captcha']){
mail($to, $subject, $message, $headers);
echo 'Votre message à été envoyé';
}else{
echo 'Le captcha entré est invalide. <a href="/index.php">Recommencez</a>';
}
?>
</body>
</html>
J'ai une page aussi nommée captcha
<?php
session_start();
$_SESSION['captcha'] = rand(1000,9999);
$img = imagecreatetruecolor(70,30);
$fill_color = imagecolorallocate($img,230,230,230);
imagefilledrectangle($img,0,0,70,30,$fill_color);
$text_color = imagecolorallocate($img, 10,10,10);
$font = './police.ttf';
imagettftext($img,23,0,5,30,$text_color,$font,$_SESSION['captcha']);
header("Content-type:image/jpeg");
imagejpeg($img);
imagedestroy($img);
?>
J'obtiens des erreurs, ce site n'existe pas....