dans cette page où je travaille, j'affiche mes données à travers des composants html. j'aimerais enregistrer le titre de l'annonce dans la table favoris
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
require_once 'Model/Connexion.php';
$c = new Connexion();
$c->query("select * from annonce where id_annonce=:id");
$c->bind(':id', $_GET['id']);
$r = $c->single();
?>
<!DOCTYPE html>
<html>
  <head>
 
    <title>Détails d'annonce</title>
</head>
  <body>
    <div id="Wraper">
  <div id="Middle">
    <div class="Left">
 
    <div class="Content FCKeditor">
          <h1><?php echo($r['profil']); ?></h1>
          <div class="Jobdetails">
              <form method="GET" action="ajout_favoris.php?id_annonce = <?php echo($r['id_annonce']) ?>">
                  <p class="Date"><span></span> | 
                      <span><a href="#"><?php echo($r['clt']); ?></a></span> | 
                      <span><?php echo($r['contrat']); ?></span>
                      <span class="imageDroite">
                          <input type="submit" height="15" width="16" src="favoris-icon.png" value="ajouter aux favoris"/>
                      </span>
                  </p>
              </form>
              <?php echo text_format($r['d_annonce']); ?></br>
         </div>
 
           </div> </div>
 
    </div>
  </div>
  </body>
</html>
quand je clique sur le boutton rien ne s'enregistre dans la base de données
ajout_favoris.php
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
require_once 'Model/Connexion.php';
$c = new Connexion(); 
$c->query("insert into favoris (titre_fav) select profil from annonce where id_annonce =:id");
$c->bind(':id', $_GET['id_annonce']);//pour éviter l'injection SQL
$c->execute();
header("location: javascript:history.go(-1);");