Bonsoir a tous ,
Je suis novice en PHP :) et je voudrais savoir comment faire pour validé un commentaire sur mon site avec le captcha de chez google , le code fonctione bien mais je n'est pas d'action sur le bouton poster pour le validez .

voici mon code :

"<?php

if (isset($_POST['submit'])) {
extract($_POST);

if (!empty($nom) and !empty($email) and !empty($message)) {
    require_once('includes/db.php');

    $req=$db->prepare('INSERT INTO commentaires(nom,email,messages,datepost) VALUES(?,?,?,NOW())');
    $req->execute(array($nom,$email,$message));
}

}

?>

<!DOCTYPE html>
<html>
<center>
<img src="logo.jpg" />
</center>
<head>
<title>Annonces Help !! Malinois</title>
<meta charset="utf-8">
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<style type="text/css">
section{
width: 50%;
margin-left: auto;
margin-right: auto;
}
span{
font-size: 13px;
color:#777;
}
</style>
</head>
<body>
<section>

    <center>
   <h2>Petites Annonces</h2> <br>
    </center>
   <form method="POST" action="">
      <input type="text" name="nom" placeholder="Nom:"  required="" class="form form-control"><br>
      <input type="email" name="email" placeholder="Email:"  required="" class="form form-control"><br>
      <textarea name="message" placeholder="Méssage:" required="" class="form form-control"></textarea><br>
         <!-- <input type="submit" name="submit" value="Poster" class="btn btn-primary">     -->
    <center>
    <script src="https://www.google.com/recaptcha/api.js"></script>

    </center><script>

function onSubmit(token) {
document.getElementById("demo-form").submit();
}
</script>
<center>
<button class="g-recaptcha"
data-sitekey="6Ldg7BAbAAAAACgNJ1sN2zncBHufgbijqcAjN-iW"
data-callback='onSubmit'
data-action='submit'>POSTER</button>

    </center>
   </form><br><br><br><br>

   <h3>Annonces postées</h3><br>

     <?php 
         require_once('includes/db.php'); 
         $req=$db->prepare('SELECT *FROM commentaires');
         $req->execute();
         while ($reponse = $req->fetch(PDO::FETCH_OBJ)) {

        ?>
         <p>
            <span>Poster par <?php echo $reponse->nom; ?> le <?php echo $reponse->datepost; ?></span><br>
            <?php echo $reponse->messages; ?><br><a href="reponses.php?id=<?php echo $reponse->id;?> "class="btn btn-primary" >Répondre</a><br>
                <a style="color:#2DA53B" href="reponses.php?id=<?php echo $reponse->id;?>">
                    Nomre de réponses: 

                  <?php 

                  $nbReponse = $db->prepare('SELECT *FROM reponses WHERE id_parent = ?');
                  $nbReponse->execute(array($reponse->id));

                  $nbReponse = $nbReponse->fetchAll();

                  echo count($nbReponse);

                   ?>
                   <html>
                   <br>
                  <img src="ligne.jpg"/>
                </a>
            </p>
        <?php   
        }

      ?>

   <br><br><br>

</section>
</body>
</html>
"
l'adresse de mon site : https://tmc85.fr/form/Commentaires/index.php

Aucune réponse