[英]I want to update the data with php
我想用PHP更新數據。當我單擊按鈕時,頁面刷新並且不會發生更新。 如何糾正
我的代碼:文件名:Contact_settings
<form action="../netting/islem.php" method="post" class="form-horizontal form-label-left">
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Gsm Number<span class="required">*</span></label>
<div class="col-md-6 col-sm-6 col-xs-12">
<input type="text" name="ayar_tel" value="<?php echo $ayarcek['ayar_tel'] ?>" required="required" class="form-control col-md-7 col-xs-12">
</div>
<div class="form-group">
<div align="right" class="col-md-6 col-sm-6 col-xs-12 col-md-offset-3">
<button type="submit" name="iletisim" class="btn btn-success right">Güncelle</button>
</div>
</div>
文件名:islem.php
if(isset($_POST['iletisim'])){
$ayarkaydet = $db->prepare("UPDATE ayar SET
ayar_tel =:ayar_tel,
WHERE ayar_id=3
");
$update = $ayarkaydet->execute
(
array(
':ayar_tel' => $_POST['ayar_tel'],
)
);
你的代碼有錯誤
必須是這樣
if(isset($_POST['iletisim'])){
$ayarkaydet = $db->prepare("UPDATE ayar SET ayar_tel =:ayar_tel WHERE ayar_id=3 ");
$update = $ayarkaydet->execute (array(':ayar_tel' => $_POST['ayar_tel']));
}
我在你的 sql where 和你的 execute 數組中刪除了兩個逗號,並為 if 語句添加了一個 close } 。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.