Partage
  • Partager sur Facebook
  • Partager sur Twitter

verification systeme news

tout est rempli mais le script me dit le contraire

    27 janvier 2007 à 17:37:21

    bonjour tout le monde
    j'ai un script de news et quand je veux en ajouter une, je rempli tout les champs et quand je valide:

    Citation : mon site

    Ooops, il y a un champ vide ! Les champs obligatoires sont : Titre, Date & Heure News, Signature, Email Signature. Les options ne sont pas obligatoires dans une News, mais veillez à ne pas cocher les cases correspondantes.


    les 2 codes sont ajouter.php3:


    <html>
    <head>
    <title>ADMIN - MyNEWS v1.2</title>
    <style>
    .m10,.m9,.m10b,.m9b {font-family:geneva,arial;}
    .m8,.m8b {font-family:verdana;}
    .m10,.m10b {font-size:10pt;}
    .m9,.m9b {font-size:9pt;}
    .m8,.m8b {font-size:8pt;}
    .m10b,.m9b,.m8b {font-weight:bold;}
    </style>
    </head>

    <body bgcolor="#EEEEFC">

    <?
    $date = date("d/m/Y");
    $heure = date("H:i");
    ?>

    <!-- FORMULAIRE AJOUTER UNE NEWS ---------------------->
    <form method="POST" action="ajouter_verif.php3">
    <div align="center">
      <center>
      <table border="0" cellpadding="0" cellspacing="0" width="600" bgcolor="#C5C6E3">
        <tr>
          <td height="30" bgcolor="#7E80E2" align="center" class="m10">
            <font color="#FFFFFF"><b>Insertion d'une News</b></font></td>
        </tr>
        <tr>
          <td height="20">&nbsp;</td>
        </tr>
        <tr>
          <td height="20" class="m9"><center>Titre : <input type="text" name="titre" size="62"></center></td>
        </tr>
        <tr>
          <td height="20">&nbsp;</td>
        </tr>
        <tr>
          <td height="20" class="m9"><center>Date : <input type="text" name="date" value="<? echo $date; ?>" size="9">
            &amp; Heure : <input type="text" name="heure" value="<? echo $heure; ?>" size="7">
            de la news</center></td>
        </tr>
        <tr>
          <td height="20"><center></center>&nbsp;</td>
        </tr>
        <tr>
          <td height="20" class="m9"><center><textarea WRAP="virtual" rows="14" cols="60" name="news">Ici le corps de la news ...</textarea></center></td>
        </tr>
        <tr>
          <td height="20"><center></center>&nbsp;</td>
        </tr>
        <tr>
          <td height="20" class="m9"><center>Signature : <input type="text" name="signature" size="20"> Email sur signature : <input type="text" name="email_sign" size="20"></center></td>
        </tr>
        <tr>
          <td height="20">&nbsp;</td>
       </tr>

    <!-- Boutons -->
      <tr>
       <td height="70" bgcolor="#EEEEFC" align="center">
          <input type="button" value="<< Retour menu principal" onClick="Javascript:window.location='
    index.php3';" Style="width: 295px">
          <input type="submit" value="Ajouter la news >>" Style="width: 295px">
       </td>
      </tr>
    <!-- Boutons -->

        <tr>
          <td height="30" bgcolor="#7E80E2" align="center" class="m10">
            <font color="#FFFFFF"><b>Options de la News</b></font></td>
        </tr>
        <tr>
          <td height="20" bgcolor="#C5C6E3" class="m9">
            <blockquote>
              <p><input type="checkbox" name="source" value="oui">
              <b>Cochez pour insérer une source à la news </b>(optionnel)<b>.</b></p>
             <p>Titre de la Source : <input type="text" name="nom_source" size="33"></p>
             <p>Donnez le lien à mettre sur la source : <input type="text" name="url_source" size="33" value="http://"></p>
            </blockquote>
          </td>
        </tr>
        <tr>
          <td height="20">
            <hr size="1" color="#000000">
         </td>
      </tr>
        <tr>
         <td height="20" bgcolor="#C5C6E3">
            <blockquote>
              <font class="m9">
              <p><input type="checkbox" name="image" value="oui">
              <b>Cochez pour insérer une image à droite de la news </b>(optionnel)<b>.</b></p>
              <p>Le chemin de l'
    image : <input type="text" name="path_image" size="33" value="http://">
              <font color="#FF0000"><b>(120x90 pixels !)</b></font></p>
              <p>Lien à placer sur l'image : <input type="text" name="url_image" size="33" value="http://"></p>
              </font>
            </blockquote>
        </td>
       </tr>
     <tr>
        <td height="20">&nbsp;</td>
      </tr>
    </table>
    </center>
    </div>
    </form>
    </body>
    </html>
     


    et le ajouter_verif.php3:


    <?
    if(empty($titre) OR empty($news) OR empty($date) OR empty($heure) OR empty($signature) OR empty($email_sign))
         {
         ?>
         <script language="Javascript">
         alert('Ooops, il y a un champ vide !\n\nLes champs obligatoires sont :\n\nTitre\nDate & Heure\nNews\nSignature\nEmail Signature\n\nLes options ne sont pas obligatoires dans une News, mais veillez à ne pas cocher les cases correspondantes.');
         history.back();
         </script>
         <?
         }
    elseif($source=='oui' AND empty($nom_source) OR empty($url_source))
         {
         ?>
         <script language="Javascript">
         alert('Ooops, il y a un champ vide dans la partie \'Source de la news\' !');
         history.back();
         </script>
         <?
         }
    elseif($image=='oui' AND empty($path_image) OR empty($url_image))
         {
         ?>
         <script language="Javascript">
         alert('Ooops, il y a un champ vide dans la partie \'Ajouter une image\' !');
         history.back();
         </script>
         <?
         }
    else
         {
         require("../config.inc.php3");

    $db = mysql_connect("localhost", "login", "mdp") or Die("Base Down !");
    mysql_select_db("haha",$db) or Die("Base Down !");

         $date_verif = date("Y-m-d H:i:s");

         if($source!='oui'){ $source = "non"; $nom_source = ""; $url_source=""; }
         if($image!='oui'){ $image = "non"; $path_image = ""; $url_image = ""; }

         $titre      = addslashes(stripslashes(trim($titre)));
         $signature  = addslashes(stripslashes(trim($signature)));
         $email_sign = addslashes(stripslashes(strtolower(trim($email_sign))));
         $nom_source = addslashes(stripslashes(trim($nom_source)));
         $url_source = addslashes(stripslashes(trim($url_source)));
         $path_image = addslashes(stripslashes(trim($path_image)));
         $url_image  = addslashes(stripslashes(trim($url_image)));
         $news       = nl2br($news);
         $news       = addslashes(stripslashes(trim($news)));

         $rqt = mysql_query("INSERT INTO $TBL_NEWS VALUES('','$titre','$date_verif','$date','$heure','$signature','$email_sign','$source','$nom_source','$url_source','$image','$path_image','$url_image','$news')");

         if(!$rqt){ echo "<font class=m9 color=red><b>La requête a échouée !\n<br>La news n'a pas été enregistrée ...\n<br>Faites '<< Précédent' et ré-essayez ...</b></font>"; }
         else
            {
            ?>
             <script language="Javascript">
             window.location='index.php3?m=1';
             </script>
            <?
            }
         }
    ?>


    Pouvez vous m'aider?
    • Partager sur Facebook
    • Partager sur Twitter
      27 janvier 2007 à 17:42:56

      // Remplace:
      if(empty($titre) OR empty($news) OR empty($date) OR empty($heure) OR empty($signature) OR empty($email_sign))

      // Par:
      if(empty($_POST['titre']) OR empty($_POST['news']) OR empty($_POST['date']) OR empty($_POST['heure']) OR empty($_POST['signature']) OR empty($_POST['email_sign']))
      • Partager sur Facebook
      • Partager sur Twitter
      Erreur PDO - Installation Wamp - Docs PHP et MYSQL.
        27 janvier 2007 à 18:09:15

        lol mais oui :euh:
        merci beaucoup mais j'ai fais la meme chose partout et ça donne ça(ajouter_verif.php3):

        <?
        if(empty($_POST['titre']) OR empty($_POST['news']) OR empty($_POST['date']) OR empty($_POST['heure']) OR empty($_POST['signature']) OR empty($_POST['email_sign']))
             {
             ?>
             <script language="Javascript">
             alert('Ooops, il y a un champ vide !\n\nLes champs obligatoires sont :\n\nTitre\nDate & Heure\nNews\nSignature\nEmail Signature\n\nLes options ne sont pas obligatoires dans une News, mais veillez à ne pas cocher les cases correspondantes.');
             history.back();
             </script>
             <?
             }
        elseif(($_POST['source'])=='oui' AND empty($_POST['nom_source']) OR empty($_POST['url_source']))
             {
             ?>
             <script language="Javascript">
             alert('Ooops, il y a un champ vide dans la partie \'Source de la news\' !');
             history.back();
             </script>
             <?
             }
        elseif(($_POST['image'])=='oui' AND empty($_POST['path_image']) OR empty($_POST['url_image']))
             {
             ?>
             <script language="Javascript">
             alert('Ooops, il y a un champ vide dans la partie \'Ajouter une image\' !');
             history.back();
             </script>
             <?
             }
        else
             {
             require("../config.inc.php3");

        $db = mysql_connect("", "", "") or Die("Base Down !");
        mysql_select_db("",$db) or Die("Base Down !");

             $date_verif = date("Y-m-d H:i:s");

             if($source!='oui'){ $source = "non"; $nom_source = ""; $url_source=""; }
             if($image!='oui'){ $image = "non"; $path_image = ""; $url_image = ""; }

             $titre      = addslashes(stripslashes(trim($titre)));
             $signature  = addslashes(stripslashes(trim($signature)));
             $email_sign = addslashes(stripslashes(strtolower(trim($email_sign))));
             $nom_source = addslashes(stripslashes(trim($nom_source)));
             $url_source = addslashes(stripslashes(trim($url_source)));
             $path_image = addslashes(stripslashes(trim($path_image)));
             $url_image  = addslashes(stripslashes(trim($url_image)));
             $news       = nl2br($news);
             $news       = addslashes(stripslashes(trim($news)));

             $rqt = mysql_query("INSERT INTO $mynewsinfos VALUES('$_POST['titre']','$_POST['date_verif']','$_POST['date']','$_POST['heure']','$_POST['signature']','$_POST['email_sign']','$_POST['source']','$_POST['nom_source']','$_POST['url_source']','$_POST['image']','$_POST['path_image']','$_POST['url_image']','$_POST['news']'");

             if(!$rqt){ echo "<font class=m9 color=red><b>La requête a échouée !\n<br>La news n'a pas été enregistrée ...\n<br>Faites '<< Précédent' et ré-essayez ...</b></font>"; }
             else
                {
                ?>
                 <script language="Javascript">
                 window.location='index.php3?m=1';
                 </script>
                <?
                }
             }
        ?>

        Parse error: syntax error, unexpected T_ENCAPSED_AND_WHITESPACE, expecting T_STRING or T_VARIABLE or T_NUM_STRING in /home/wiisite/adm
        in/ajouter_verif.php3 on line 51

        voila encore et toujours des erreurs xD
        merci de m'aider.
        • Partager sur Facebook
        • Partager sur Twitter
          27 janvier 2007 à 18:21:04

          Déplace cette partie de code:
               $titre      = addslashes(stripslashes(trim($titre)));
               $signature  = addslashes(stripslashes(trim($signature)));
               $email_sign = addslashes(stripslashes(strtolower(trim($email_sign))));
               $nom_source = addslashes(stripslashes(trim($nom_source)));
               $url_source = addslashes(stripslashes(trim($url_source)));
               $path_image = addslashes(stripslashes(trim($path_image)));
               $url_image  = addslashes(stripslashes(trim($url_image)));
               $news       = nl2br($news);
               $news       = addslashes(stripslashes(trim($news)));

          (place le sous ton premier if()) et au passage, ça sert à rien de mettre un addslashes() pour y mettre un stripslashes() à la suite...

          Ensuite modifie cette portion de code (le bout déplacer)
               $titre      = addslashes(trim($_POST['titre']));
               $signature  = addslashes(trim($_POST['signature']));
               $email_sign = addslashes(strtolower(trim($_POST['email_sign'])));
               $nom_source = addslashes(trim($_POST['nom_source']));
               $url_source = addslashes(trim($_POST['url_source']));
               $path_image = addslashes(trim($_POST['path_image']));
               $url_image  = addslashes(trim($_POST['url_image']));
               $news       = nl2br(addslashes$_POST['news']));
          • Partager sur Facebook
          • Partager sur Twitter
          Erreur PDO - Installation Wamp - Docs PHP et MYSQL.
            28 janvier 2007 à 10:46:33

            et ben....pareil :'(
            maitenant mon code est:

            <?
            if(empty($_POST['titre']) OR empty($_POST['news']) OR empty($_POST['date']) OR empty($_POST['heure']) OR empty($_POST['signature']) OR empty($_POST['email_sign']))
                 {
                 ?>
                 <script language="Javascript">
                 alert('Ooops, il y a un champ vide !\n\nLes champs obligatoires sont :\n\nTitre\nDate & Heure\nNews\nSignature\nEmail Signature\n\nLes options ne sont pas obligatoires dans une News, mais veillez à ne pas cocher les cases correspondantes.');
                 history.back();
                 </script>
                 <?
                 }
            elseif(($_POST['source'])=='oui' AND empty($_POST['nom_source']) OR empty($_POST['url_source']))
                 {
                 ?>
                 <script language="Javascript">
                 alert('Ooops, il y a un champ vide dans la partie \'Source de la news\' !');
                 history.back();
                 </script>
                 <?
                 }
            elseif(($_POST['image'])=='oui' AND empty($_POST['path_image']) OR empty($_POST['url_image']))
                 {
                 ?>
                 <script language="Javascript">
                 alert('Ooops, il y a un champ vide dans la partie \'Ajouter une image\' !');
                 history.back();
                 </script>
                 <?
                 }
            else
                 {
                 require("../config.inc.php3");

            $db = mysql_connect("localhost", "", "") or Die("Base Down !");
            mysql_select_db("",$db) or Die("Base Down !");

                 $date_verif = date("Y-m-d H:i:s");

                 if($source!='oui'){ $source = "non"; $nom_source = ""; $url_source=""; }
                    
                     $titre      = addslashes(trim($_POST['titre']));
                 $signature  = addslashes(trim($_POST['signature']));
                 $email_sign = addslashes(strtolower(trim($_POST['email_sign'])));
                 $nom_source = addslashes(trim($_POST['nom_source']));
                 $url_source = addslashes(trim($_POST['url_source']));
                 $path_image = addslashes(trim($_POST['path_image']));
                 $url_image  = addslashes(trim($_POST['url_image']));
                 $news       = nl2br(addslashes($_POST['news']));
                    

                 if($image!='oui'){ $image = "non"; $path_image = ""; $url_image = ""; }
            <!-- la ligne d'en bas de ce commentaire qui bug ^^ -->
                 $rqt = mysql_query("INSERT INTO $mynewsinfos VALUES('
            $_POST['titre']','$_POST['date_verif']','$_POST['date']','$_POST['heure']','$_POST['signature']','$_POST['email_sign']','$_POST['source']','$_POST['nom_source']','$_POST['url_source']','$_POST['image']','$_POST['path_image']','$_POST['url_image']','$_POST['news']'");

                 if(!$rqt){ echo "<font class=m9 color=red><b>La requête a échouée !\n<br>La news n'
            a pas été enregistrée ...\n<br>Faites '<< Précédent' et ré-essayez ...</b></font>"; }
                 else
                    {
                    ?>
                     <script language="
            Javascript">
                     window.location='index.php3?m=1';
                     </script>
                    <?
                    }
                 }
            ?>
             


            deja un grand merci por l'aide deja aporter!
            • Partager sur Facebook
            • Partager sur Twitter

            verification systeme news

            × Après avoir cliqué sur "Répondre" vous serez invité à vous connecter pour que votre message soit publié.
            × Attention, ce sujet est très ancien. Le déterrer n'est pas forcément approprié. Nous te conseillons de créer un nouveau sujet pour poser ta question.
            • Editeur
            • Markdown