Recherche d'erreur

Fermé
Carl - Modifié le 3 janv. 2018 à 20:31
9995 Messages postés 2 Date d'inscription mercredi 3 janvier 2018 Statut Membre Dernière intervention 3 janvier 2018 - 3 janv. 2018 à 20:13
Bonjour,

s' il vous plait quelque pourrait il m'aider à trouver lerreur?

quand j'essaye d'envoyer le formulaire ca me renvoit ceci:


Parse error: syntax error, unexpected '{' in C:\Program Files (x86)\EasyPHP-Devserver-17\eds-www\web\mon site web\formulaire.php on line 78

voila le code:

<?php
// Couleur du texte des champs si erreur saisie utilisateur
$color_font_warn="#FF0000";
// Couleur de fond des champs si erreur saisie utilisateur
$color_form_warn="#FFCC66";
// Ne rien modifier ci-dessous si vous n’êtes pas certain de ce que vous faites !

$list['f_10']=array("Sélectionnez","Homme"," Femme");
if(isset($_POST['submit'])){
 $erreur="";
 // Nettoyage des entrées
 while(list($var,$val)=each($_POST))
 {
  if(!is_array($val))
  {
   $$var=strip_tags($val);
  }
  else
  {
   while(list($arvar,$arval)=each($val))
    {
     $$var[$arvar]=strip_tags($arval);
    }
  }
 }
 // Formatage des entrées
 $f_1=trim(ucwords(preg_replace("[^a-zA-Z0-9éèàäö\ -]", "", $f_1)));
 $f_2=trim(ucwords(preg_replace("[^a-zA-Z0-9éèàäö\ -]", "", $f_2)));
 $f_3=trim(ucwords(preg_replace("[^a-zA-Z0-9éèàäö\ -]", "", $f_3)));
 $f_4=trim(preg_replace("[^0-9+]", "", $f_4));
 $f_5=trim(ucwords(preg_replace("[^a-zA-Z0-9éèàäö\ -]", "", $f_5)));
 $f_6=trim(ucwords(preg_replace("[^a-zA-Z0-9éèàäö\ -]", "", $f_6)));
 $f_7=strip_tags(trim($f_7));
 $f_8=trim(preg_replace("[^0-9\ +]", "", $f_8));
 // Verification des champs
 if(strlen($f_1)<2){
  $erreur.="<li><span class='txterror'>Le champ « Nom » est vide ou incomplet.</span>";
  $errf_1=1;
 }
 if(strlen($f_2)<2){
  $erreur.="<li><span class='txterror'>Le champ « Prenom » est vide ou incomplet.</span>";
  $errf_2=1;
 }
 if(strlen($f_3)<2){
  $erreur.="<li><span class='txterror'>Le champ « Rue » est vide ou incomplet.</span>";
  $errf_3=1;
 }
 if(strlen($f_4)<2){
  $erreur.="<li><span class='txterror'>Le champ « Code postale » est vide ou incomplet.</span>";
  $errf_4=1;
 }
 if(strlen($f_5)<2){
  $erreur.="<li><span class='txterror'>Le champ « Ville » est vide ou incomplet.</span>";
  $errf_5=1;
 }
 if(strlen($f_6)<2){
  $erreur.="<li><span class='txterror'>Le champ « Pays » est vide ou incomplet.</span>";
  $errf_6=1;
 }
 if($f_10==0){
  $erreur.="<li><span class='txterror'>Le champ « Sexe » n'a pas été défini.</span>";
  $errf_10=1;
 }
 if($erreur=="")
 {
  // Création du message
  $titre="Message de votre site";
  $corps="Nom : ".$f_1."\n";
  $corps.="Prenom : ".$f_2."\n";
  $corps.="Rue : ".$f_3."\n";
  $corps.="Code postale : ".$f_4."\n";
  $corps.="Ville : ".$f_5."\n";
  $corps.="Pays : ".$f_6."\n";
  $corps.="E-Mail : ".$f_7."\n";
  $corps.="Tel : ".$f_8."\n";
  $corps.="Sexe : ".$list['f_10'][$f_10]."\n";
  if(mail("***@***", $titre, stripslashes($corps))
  {
   $ok_mail="true";
  }
  else
  {
   $erreur.="<li><span class='txterror'>Une erreur est survenue lors de l'envoi du message, veuillez refaire une tentative.</span>";
  }
 }
}
?>

<!DOCTYPE html>
<html>

<head>
    <title>formulaire</title>
 <meta charset="utf-8" />
 <style type="text/css" media="screen"><!--
 INPUT { color: #000; font-size: 11px; font-family: verdana, Arial, Helvetica, Geneva, Swiss, SunSans-Regular; background-color: #EEEEEE }
 SELECT { color: #000; font-size: 11px; font-family: verdana, Arial, Helvetica, Geneva, Swiss, SunSans-Regular; background-color: #EEEEEE }
 TEXTAREA { color: #000; font-size: 11px; font-family: verdana, Arial, Helvetica, Geneva, Swiss, SunSans-Regular; background-color: #EEEEEE }
 .txterror { color: black; font-size: 11px; font-family: Verdana, Arial, Helvetica, Geneva, Swiss, SunSans-Regular }
 .txtform { color: black; font-size: 12px; font-family: Verdana, Arial, Helvetica, Geneva, Swiss, SunSans-Regular }
 --></style>
</head>

<body>

<?php 
 if(isset($ok_mail) && $ok_mail=="true")
 {  ?>
 <table width='100%' border='0' cellspacing='1' cellpadding='1'>
  <tr><td><span class='txtform'>Le message ci-dessous nous a bien été transmis, et nous vous en remercions.</span></td></tr>
  <tr><td> </td></tr>
  <tr><td><tt><?php echo nl2br(stripslashes($corps));?></tt></td></tr>
  <tr><td> </td></tr>
  <tr><td><span class='txtform'>Nous allons y donner suite dans les meilleurs délais.<br>A bientôt.</span></td></tr>
 </table>
<?php 
 }
 else
 { ?>
  <form action='#' method='post' name='Form'>
  <table width='100%' border='0' cellspacing='1' cellpadding='1'>
  <?php if(isset($erreur) ){ ?><tr><td colspan='2' bgcolor='red'><span class='txterror'><font color='white'><b> ERREUR, votre message n'a pas été transmis</b></font></span></td></tr><tr><td colspan='2'><ul><?phpecho$erreur?></ul></td></tr><?php } ?>
  <tr><td colspan='2'><span class='txterror'>Les champs marqué d'un * sont obligatoires</span></td></tr>
  <tr><td align='right' width='30%'><span class='txtform'>Nom* :</span></td><td><input type='text' style='width:200 <?php if($errf_1==1){print("; background-color: ".$color_form_warn."; color: ".$color_font_warn);}?>;' name='f_1' value='<?php if(isset($f_1)) {echo stripslashes($f_1);} ?>' size='24' border='0'></td></tr>
  <tr><td align='right' width='30%'><span class='txtform'>Prenom* :</span></td><td><input type='text' style='width:200 <?php if($errf_2==1){print("; background-color: ".$color_form_warn."; color: ".$color_font_warn);}?>;' name='f_2' value='<?php if(isset($f_2)) {echo stripslashes($f_2);} ?>' size='24' border='0'></td></tr>
  <tr><td align='right' width='30%'><span class='txtform'>Rue* :</span></td><td><input type='text' style='width:200 <?php if($errf_3==1){print("; background-color: ".$color_form_warn."; color: ".$color_font_warn);}?>;' name='f_3' value='<?php if(isset($f_3)) {echo stripslashes($f_3);} ?>' size='24' border='0'></td></tr>
  <tr><td align='right' width='30%'><span class='txtform'>Code postale* :</span></td><td><input type='text' style='width:200 <?php if($errf_4==1){print("; background-color: ".$color_form_warn."; color: ".$color_font_warn);}?>;' name='f_4' value='<?php if(isset($f_4)) {echo stripslashes($f_4);} ?>' size='24' border='0'></td></tr>
  <tr><td align='right' width='30%'><span class='txtform'>Ville* :</span></td><td><input type='text' style='width:200 <?php if($errf_5==1){print("; background-color: ".$color_form_warn."; color: ".$color_font_warn);}?>;' name='f_5' value='<?php if(isset($f_5)) {echo stripslashes($f_5);} ?>' size='24' border='0'></td></tr>
  <tr><td align='right' width='30%'><span class='txtform'>Pays* :</span></td><td><input type='text' style='width:200 <?php if($errf_6==1){print("; background-color: ".$color_form_warn."; color: ".$color_font_warn);}?>;' name='f_6' value='<?php if(isset($f_6)) {echo stripslashes($f_6);} ?>' size='24' border='0'></td></tr>
  <tr><td align='right' width='30%'><span class='txtform'>E-Mail :</span></td><td><input type='text' style='width:200 <?php if($errf_7==1){print("; background-color: ".$color_form_warn."; color: ".$color_font_warn);}?>;' name='f_7' value='<?php if(isset($f_7)) {echo stripslashes($f_7);} ?>' size='24' border='0'></td></tr>
  <tr><td align='right' width='30%'><span class='txtform'>Tel :</span></td><td><input type='text' style='width:200 <?php if($errf_8==1){print("; background-color: ".$color_form_warn."; color: ".$color_font_warn);}?>;' name='f_8' value='<?php if(isset($f_8)) {echo stripslashes($f_8);} ?>' size='24' border='0'></td></tr>
  

  <tr><td align='right' width='30%'><span class='txtform'>Sexe* :</span></td><td><select style='width:200 <?php if($errf_10==1){print("; background-color: ".$color_form_warn."; color: ".$color_font_warn);}?>;' name='f_10' size='1'>
  <?php 
  for($id=0;$id<count($list['f_10']);$id++)
   {
    if($id==$f_10){$ct="selected";}
    print("<option ".$ct." value=".$id.">".$list['f_10'][$id]."</option>");
    unset($ct);
   }?>
  </select></td></tr>

  <tr><td align='right' width='30%'></td><td><input type='submit' name='submit' value='Envoyer' border='0'></td></tr>
  </table>
  </form>
<?php
 } ?>

</body>
</html>


EDIT : Ajout des balises de code (la coloration syntaxique).
Explications disponibles ici : ICI

Merci d'y penser dans tes prochains messages.

1 réponse

yg_be Messages postés 22707 Date d'inscription lundi 9 juin 2008 Statut Contributeur Dernière intervention 19 avril 2024 1 471
3 janv. 2018 à 20:09
bonsoir, le message d'erreur t'informe que php est surpris par l'accolade ouvrante en ligne 78.
en effet, il manque une parenthèse fermante en ligne 77.
0
9995 Messages postés 2 Date d'inscription mercredi 3 janvier 2018 Statut Membre Dernière intervention 3 janvier 2018
3 janv. 2018 à 20:11
merci infiniment
0
9995 Messages postés 2 Date d'inscription mercredi 3 janvier 2018 Statut Membre Dernière intervention 3 janvier 2018
3 janv. 2018 à 20:13
par contre cette erreur corrige, j'arrive pas toujours a envoyer le formulaire par mail.

svp y a t'il une autre erreur sur la fonction : mail(.....)?
0