在此頁面上,我通過html組件顯示數據。我會保存列「PROFIL」從列表retrived表「favoris」保存數據回收
<?php
require '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="post" action="ajout_favoris.php?<?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>
當我按一下按鈕沒有被保存在數據庫中。 ajout_favoris.php
<?php
require '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']);
$c->execute();
header("location: javascript:history.go(-1);");
?>
我認爲你應該使用'$ _POST'而不是'$ _GET' 並在'ajout_favoris.php'中加入'print_r'' $ _POST'並檢查。 也發佈錯誤日誌,如果有的話 – 2014-09-30 10:39:47