06 Mayıs 2024 10:58, Pazartesi 6067 0
// baglan.php
<?php
$host="localhost";
$user="root";
$pass="";
$db="sitem";
//mysql bağlantısı
$baglan=@mysql_pconnect($host, $user, $pass);
//veri tabanı bağlantısı
$vtbaglanti=mysql_select_db($db, $baglan);
//mysql türkçe karakter düzeltme
mysql_query("SET NAMES UTF8");
?>
// uyeeklelistele.php
<?php include("baglan.php");
$sonuc=""; // kayıt sonucu için değişken
if ($_POST) {
$adsoyad=$_POST["ad"];
$yas=$_POST["yas"];
$mail=$_POST["mail"];
$sifre=$_POST["sifre"];
$resim=$_POST["resim"];
// veri tababnına kayıt ekleme
mysql_query("insert into uyeler (adsoyad,yas,mail,sifre,resim) values ('$adsoyad','$yas','$mail','$sifre','$resim')");
$sonuc="Kayıt Başarılı";
}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC" crossorigin="anonymous">
<title>PHP VERİ EKLEME - LİSTELEME</title>
</head>
<body>
<div class="container">
<!-- ÜYE EKLEME FORMU -->
<h1>Yeni Üye</h1>
<p style="color:#090"> <?php echo $sonuc; ?> </p>
<form action="" method="post">
<!--Ad Soyad -->
<div class="mb-3">
<label for="ad" class="form-label">Ad Soyad</label>
<input type="text" class="form-control" name="ad" id="ad">
</div>
<!--Yaş -->
<div class="mb-3">
<label for="yas" class="form-label">Yaşınız</label>
<input type="number" class="form-control" name="yas" id="yas">
</div>
<!--Mail -->
<div class="mb-3">
<label for="mail" class="form-label">Mail</label>
<input type="mail" class="form-control" name="mail" id="mail">
</div>
<!--Şifre -->
<div class="mb-3">
<label for="sifre" class="form-label">Şifre</label>
<input type="password" class="form-control" name="sifre" id="sifre">
</div>
<!--Resim -->
<div class="mb-3">
<label for="resim" class="form-label">Resim</label>
<input class="form-control" type="file" id="resim" name="resim">
</div>
<button type="submit" class="btn btn-primary">Kaydet</button>
</form>
<!--ÜYELERİ LİSTELEME -->
<h1 class="mt-5"> ÜYELER </h1>
<table class="table">
<thead>
<tr>
<th>id</th>
<th>Ad Soyad</th>
<th>Yaş</th>
<th>Mail</th>
<th>Şifre</th>
<th>Resim</th>
</tr>
</thead>
<tbody>
<?php
$uyeler=mysql_query("select * from uyeler"); // tabloya bağlanma
$toplam=mysql_num_rows($uyeler); // toplam kayıt (üye) sayısı
echo $toplam." kayıt<br>";
while ( $uye=mysql_fetch_array($uyeler)) { ?>
<!-- Tüm kayıtlar alınana kadar satır yeni verilerle yenileniyor..-->
<tr>
<td><?php echo $uye["id"]; ?></td>
<td><?php echo $uye["adsoyad"]; ?></td>
<td><?php echo $uye["yas"]; ?></td>
<td><?php echo $uye["mail"]; ?></td>
<td><?php echo $uye["sifre"]; ?></td>
<td><?php echo $uye["resim"]; ?></td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM" crossorigin="anonymous"></script>
</body>
</html>
Toplam 32 Makale
Lütfen yorumlarınızda saygılı, yapıcı ve anlaşılır bir dil kullanın.
Küfür, hakaret ya da spam içerikler onaylanmaz.