使用HTML表单输入和ph​​p更新MySQL

时间:2018-02-22 09:43:40

标签: php mysql

我在页面打开时在HTML表单输入中有MYSQL传入数据。当我在更改信息后按更新按钮时,更新操作成功,但数据未更新。

<?php


$servername = "";
$username = "";
$password = "";
$dbname = "";

$baglan = mysqli_connect($servername,$username,$password,$dbname) or die(myslqi_error());


$place = $_POST['n_place'];
$description = $_POST['n_description'];
$latitude = $_POST['lat'];
$longitude = $_POST['long'];
$kayitliyer = $_POST['search_new_places'];
$yetkiliad = $_POST['n_yetkiliad'];
$magazaad = $_POST['n_magazaad'];
$telefon = $_POST['n_telefon'];
$yetkilitelefon = $_POST['y_telefon'];
$derece = $_POST['derece'];
$country = $_POST['country'];


$sql =  "UPDATE tbl_places SET place='$place',description='$description',lat='$latitude', lng='$longitude', kayitliyer='$kayitliyer',
yekiliad='$yetkiliad', magazaad='$magazaad', telefon='$telefon', yetkilitelefon='$yetkilitelefon', derece='$derece' WHERE place_id='$gID' ";



if (mysqli_query($baglan,$sql)) {
  echo '<br/><div class="container"><div class="alert alert-success" role="alert">
              Kayıt Güncelleme <b>Başarılı :-)</b> <a href=javascript:history.back(-1)>Geri Dön</a>
             </div></div> ';
}else {
  echo '<br/><div class="container"><div class="alert alert-danger" role="alert">
              Güncelleme İşlemi <b>Başarız!</b> <a href=javascript:history.back(-1)>Geri Dön</a>
             </div></div>'. mysqli_error($baglan);
}



?>

HTML页面表单SELECT Query.Thanks您的回复。我得到&#34; $ gID&#34;的价值从HTML表单页面,我使用SELECT query.UPDATE

输入数据库数据
  <?php
 //UPDATE ID
   $gID = $_GET["place_id"];

   include ("baglanti.php");

 $sorgu = mysqli_query($baglan,"select * from tbl_places where place_id='$gID'");


  while($goster = mysqli_fetch_array($sorgu)){
  $grupadi = $goster["place"];
  $id = $goster["place_id"];
  $desc = $goster["description"];
  $adres = $goster["kayitliyer"];
  $yetkiliad = $goster["yekiliad"];
  $magazaad = $goster["magazaad"];
  $telefon = $goster["telefon"];
  $yetkilitelefon = $goster["yetkilitelefon"];
  $derece = $goster["derece"];
  $country = $goster["country"];
  $lat =$goster["lat"];
  $long = $goster["lng"];
  }
 ?>
<!DOCTYPE html>
<html lang="tr">
<head>

1 个答案:

答案 0 :(得分:-3)

为了安全性和代码清洁,您应该使用PDO。除此之外,如果没有关于INotifyPropertyChanged来自何处的更多信息,我会尝试删除与其进行比较的值的单引号,因为它可能是整数而不是字符串:

$gID