Blog yazı düzenleme sayfası oluşturuyorum, devamlı yaptığım prepare ile yapmaya çalıştım ama bir yerde hata var ve bunu göremiyorum sanırsam. Konu hakkında çözümlerinizi bekliyorum
blog-edit.php kullandığım update methodu.
<?php
session_start();
error_reporting(0);
include('includes/config.php');
if(strlen($_SESSION['alogin'])==0)
{
header('location:index.php');
}
else{
if(isset($_POST['submit']))
{
$id=$_GET['link'];
$title=$_POST['title'];
$description=$_POST['description'];
$img=$_POST['img'];
$sql="update posts set title=:title,description=:description,img=:img where id=:link";
$query = $dbh->prepare($sql);
$query->bindParam(':title',$wpname,PDO::PARAM_STR);
$query->bindParam(':description',$wpaddress,PDO::PARAM_STR);
$query->bindParam(':img',$wpcnumber,PDO::PARAM_STR);
$query->bindParam(':id',$id,PDO::PARAM_STR);
$query->execute();
echo "<script>alert('Car wash point updated successfully');</script>";
echo "<script>window.location.href ='managecar-washingpoints.php'</script>";
}
?>Yazıyı İD ile bu şekilde çekiyorum
<h3 class="col-sm-2 control-label">Yazı Düzenle</h3>
<?php
include('includes/config.php');
$link = @$_GET["link"];
$data = $dbh->prepare("SELECT * from posts WHERE id=?");
$data->execute([
$link
]);
$_data = $data->fetch(PDO::FETCH_ASSOC);?>
<div class="tab-content">
<div class="tab-pane active" id="horizontal-form">
<form class="form-horizontal" name="posts" method="post" enctype="multipart/form-data">
<div class="form-group">
<label for="focusedinput" class="col-sm-2 control-label"></label>
<div class="col-sm-8">
<p>Resim</p>
<input type="text" class="form-control" name="img" id="img" value="<?php echo $_data["img"];?>" required>
<hr>
<p>Başlık</p>
<input type="text" class="form-control" name="title" id="title" value="<?php echo $_data["title"];?>" required>
<hr>
<p>İçerik</p>
<textarea rows="20" type="text" class="form-control" name="description" id="description" value="<?php echo $_data["description"];?>" required></textarea>
</div>
</div>
<div class="form-group">
<div class="row">
<div class="col-sm-8 col-sm-offset-2">
<button type="submit" name="submit" class="btn-primary btn">Güncelle</button>
</div>
</div>
</div>
</form>