Mon erreur ne s'affiche pas PHP [Résolu/Fermé]

Messages postés
119
Date d'inscription
samedi 30 mai 2015
Statut
Membre
Dernière intervention
8 mars 2019
-
bonjours, je veux juste savoir pourquoi mon $errMessage ne s'affiche pas :/
pour eviter d'abimer vos yeux, c'est a la ligne 203
mon code :
<?php
session_start();
require('../bdd.php');
if(isset($_SESSION['rang']))
{
 if(isset($_POST['sub_contest']))
 {
  if(!empty($_POST['title_contest']) && !empty($_POST['content_contest']))
  {
   $tailleMax = 5000000;
   $extensionValide = array('jpg', 'jpeg', 'png', 'gif');

   if($_FILES['image']['size'] <= $tailleMax)
   {
    $extensionUpload = strtolower(substr(strrchr($_FILES['image']['name'], '.'), 1));
    if(in_array($extensionUpload, $extensionValide))
    {

     $way = "concours/".$_POST['title_contest'].".".$extensionUpload;
     $result = move_uploaded_file($_FILES['image']['tmp_name'], $way);
     if($result)
     {
      $dest_image = $sujetInfos['id'].".".$extensionUpload;
      $fileName = $_POST['title_contest'];
      $originCharacters = 'àçéèêîûôïöüâä';
      $destinCharacters = 'aceeeiuoiouaa';
      $fileName = strtr($fileName, $originCharacters, $destinCharacters);
      $fileName = preg_replace('/[^a-z0-9-]/', '-', $fileName);
      $fileName = $fileName.'.txt';
      $fileContent = json_encode("utf-8")."\n";
      $fileContent = htmlspecialchars($_POST['content_contest']);
      $fileContent = $_POST['content_contest'];
      $etat = "ouvert";

      /*add contest*/
      $addContest = $bdd->prepare(' INSERT INTO contests(title, content, image, etat) VALUES(?, ?, ?, ?) ');
      $addContest->execute(array($_POST['title_contest'], $fileName, $dest_image, $etat));
      
      if (file_put_contents($fileName, $fileContent))
      {
       header('Location: ../index.php');
       exit;
      }
      else
      {
       $errMessage = "Il y a eu une érreur lors de l'importation du concours...";
      }
      header('Location: sujet.php?title='. $edit_title);
     }
     else
     {
      $errMessage = 'Une erreur c\'est produite lors de l\'importation de l\'image';
     }
    }
    else
    {
     $errMessage = 'Votre fichier doit être au format jpg, jpeg, png ou gif';
    }
   }
   else
   {
    $errMessage = 'Votre fichier ne doit pas dépasser 4Mo';
   }
  }
  else
  {
   $errMessage = "Veuillez saisir un titre et un contenu";
  }
 }
}

?>

<!doctype html>


<html lang="en" class="no-js">
<head>
 <title>Straight</title>

 <meta charset="utf-8">

 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">

 <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,400,700,600,300' rel='stylesheet' type='text/css'>
 <link rel="stylesheet" href="../css/bootstrap.css" type="text/css" media="screen">
 <link rel="stylesheet" href="../css/bootstrap-responsive.css" type="text/css" media="screen">
 <link rel="stylesheet" href="../css/jquery.fancybox.css" type="text/css" media="screen">
 <link rel="stylesheet" href="../css/style.css" type="text/css" media="screen">
    <link rel="stylesheet" href="../css/custom.css" type="text/css" media="screen">
    <link rel="stylesheet" href="../css/responsive.css" type="text/css" media="screen">

 <script type="text/javascript" src="../js/modernizr.custom.79639.js"></script>
 <noscript>
  <link rel="stylesheet" type="text/css" href="css/styleNoJS.css" />
 </noscript>
 <script type="text/javascript" src="../js/jquery.min.js"></script>
 <script type="text/javascript" src="../js/jquery.migrate.js"></script>
 <script type="text/javascript" src="../js/jquery.ba-cond.min.js"></script>
 <script type="text/javascript" src="../js/jquery.slitslider.js"></script>
 <script type="text/javascript" src="../js/jquery.nicescroll.js"></script>
 <script type="text/javascript" src="../js/bootstrap.min.js"></script>
 <script type="text/javascript" src="../js/jquery.fancybox.js"></script>
 <script type="text/javascript" src="../js/jquery.fancybox-buttons.js"></script>
 <script type="text/javascript" src="../js/script.js"></script>
<!--[if lt IE 9]>
 <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
 <link rel="stylesheet" href="css/ie8.css" type="text/css" media="screen">
<![endif]-->
 

</head>
<body>

 <!-- Container -->
 <div id="container">
 
  <!-- Header -->
  <header>
   <!-- Navbar
      ================================================== -->
   <div class="navbar navbar-inverse navbar-fixed-top">
    <div class="navbar-inner">
     <div class="container">
      <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
       <span class="icon-bar"></span>
       <span class="icon-bar"></span>
       <span class="icon-bar"></span>
      </button>
      <div class="logo">
       <a class="brand" href="index.php">
        <img alt="" src="../images/logo.png">
       </a>
      </div>
      <div class="nav-collapse collapse">
       <ul class="nav">
        <li>
         <a href="index.php">Accueil</a>        
        </li>
        <li class="drop">
         <a href="">Concours</a>
         <ul class="dropdown">
          <li><a href="">Ouvert</a></li>
          <li><a href="">Fermés</a></li>
         </ul> 
        </li>
        <li>
         <a href="">Galerie</a>
        </li>
        <li>
         <a href="chat.php">Chat</a>
        </li>
        <?php
        if(isset($_SESSION['pseudo']))
        {
         ?>
          <li class="drop">
           <a href=""><?php echo $_SESSION['pseudo']; ?></a>
            <ul class="dropdown">
             <li><a href="">Mon compte</a></li>
             <li><a href="disconnect.php">Me déconnecter</a></li>
            </ul>
          </li>
         <?php
        }
        else
        {
         ?>
          <li class="drop">
           <a href="">Mon compte</a>
            <ul class="dropdown">
             <li><a href="connect.php">Me connecter</a></li>
             <li><a href="register.php">M' inscrire</a></li>
            </ul>
          </li>
         <?php
        }
        ?>
        
       </ul>
      </div>
     </div>
    </div>
   </div>
  </header>
  <!-- End Header -->

  <br><br><br><br><br><br>

  <div class="content">
   <div class="container" style="text-align: center">
    <form method="post" action="" enctype="multipart/form-data">
     <label for="title_contest">Titre :</label>
     <input class="input_content" type="text" id="title_contest" placeholder="Titre" name="title_contest">
     <br>
     <label for="content_contest">Contenu :</label>
     <textarea style="max-height: 500px;overflow-y:scroll;" class="input_content" id="content_contest" placeholder="Contenu" name="content_contest"></textarea>
     <br>
     <label for="image_contest">Image :</label>
        <input style="border-radius: 5px;" type="file" name="image" class="input_content" id="image_contest">
        <br><br>
      <<?php if(isset($errMessage)) {?> <div class="error"> <span><?php echo $errMessage; ?></span> </div><br><br> <?php } ?>
     <input type="submit" value="Ouvrir le concours" name="sub_contest" class="input_sub">
     <br><br>
     <ul>
      <li>Votre concours doit contenir :</li>
      <br>
      <li>- Les conditions de participations.</li>
      <li>- Les récompences.</li>
      <li>- La date de fin de concours.</li>
     </ul>
    </form>
   </div> 
   <!-- End .Container -->
  </div>

 </div>
 <!-- End #Container -->
</body>
</html>


Zeelox(TM) | Graphic Designer
Afficher la suite 

1 réponse

Messages postés
186
Date d'inscription
mercredi 7 mai 2014
Statut
Membre
Dernière intervention
28 septembre 2017
16
0
Merci
Ta ligne 203 commence par un double << ce qui ne me paraît pas correct, essaye avec un seul : <?php if ...