PHP Kayıt Ekle Sil Değiştir Sayfaları

Ekle.php  isimli bir sayfa oluşturuyoruz
html>
<head>
<title> veritabanı bağlantı </title>
</head>
<body>
<form action="eklekoducalistir.php" method ="post">
<table>
  <tr>
    <td>tc:</td>
    <td><input type ="text" name="tc"/></td>
  </tr>
  <tr>
    <td>adı:</td>
    <td><input type ="text" name="adi"/></td>
  </tr>
   <tr>
    <td>soy adı:</td>
    <td><input type ="text" name="sadi"/></td>
  </tr>
  <tr>
    <td>adres:</td>
    <td><input type ="text" name="adres"/></td>
  </tr>
</table>

<input type ="submit" name="kaydet"/>
</form>
<?php

?>
</body>
</html>

daha sonra eklekoducalistir.php sayfasını yapalım

<?php
include ("baglanti.php");
$tc=$_POST['tc'];
$adi=$_POST['adi'];
$sadi=$_POST['sadi'];
$adres=$_POST['adres'];
$ekle=mysql_query("INSERT INTO kimlik (tc, adi, sadi,adres) VALUES ('$tc','$adi','$sadi','$adres')");
if ($ekle)
{echo "kayıt eklendi";}
else
{echo "kayıt ekleme hatalı";}
echo"devam için  <a href=listele.php> tıklayın <a/>" ;
?>

sil.php isminde bir sayfa oluşturun
<?php
include ("baglanti.php");
$id=$_GET['id'];
$sil=mysql_query("DELETE FROM kimlik WHERE id='$id' ");
if ($sil)
{echo "silindi";}
else
{echo "hatalı";}

echo"geri  <a href=listele.php> tıklayın <a/>" ;
?>

Değiştir için öncelikle değerleri alacağımız bir sayfa oluştururuz
degistirdegeral.php
<?php
include ("baglanti.php");
$id=$_GET['id'];
$sor= mysql_query("select * from kimlik WHERE id='$id'");
$cek=mysql_fetch_array($sor);
echo "<form action='degistir.php' method ='post'>";
$id=$cek["id"];
echo "id= <input type='text' name='id_t' value=$id>";echo "</br>";
$tc=$cek["tc"];
echo "TC= <input type='text' name='tc_t' value=$tc>";echo "</br>";
$adi=$cek["adi"];
echo "ADI= <input type='text' name='ad_t' value=$adi>";echo "</br>";
$sadi=$cek["sadi"];
echo "SOYADI= <input type='text' name='sad_t' value=$sadi>";echo "</br>";
$adres=$cek["adres"];
echo "ADRES= <input type='text' name='adres_t' value=$adres>";echo "</br>";
echo "<input type ='submit' name='kaydet'/>";
echo "</form>";
?>
kodları çalıştırmak için değiştir kod sayfasını hazırlayalım

<?php
include ("baglanti.php");
$id=$_POST['id_t'];
$TC=$_POST['tc_t'];
$AD=$_POST['ad_t'];
$SOYAD=$_POST['sad_t'];
$ADRES=$_POST['adres_t'];
$sor= mysql_query("UPDATE kimlik SET adi='$AD',sadi='$SOYAD',tc='$TC',adres='$ADRES' WHERE id='$id'");
if ($sor)
{echo "kayıt güncelleme başarılı";}
else
{echo "hatalı";}

echo"geri  <a href=listele.php> tıklayın <a/>" ;
?>

Yorumlar

Yorum Gönder