index php dosyası--------------------------------------------------------------------------------
include("config.php");
$file = simplexml_load_file("musteri.xml");
foreach ($file as $key => $value) {
$musteriID = $value->id;
$musteriAdi = $value->adi;
$musteriSoyadi = $value->soyadi;
$musteriMeslek = $value->meslek;
$musteriYasi = $value->yas;
$control = $db->prepare(" SELECT * FROM musteriler WHERE musteriID=?'$musteriID'");
$control->execute(array($musteriID));
$say = $control->rowCount();
if ($say==0)
{
$veriler = $control->fetchAll(PDO::FETCH_ASSOC);
foreach ($veriler as $veri ) {
$sql = $db->prepare("UPDATE musteriler SET musteriID=?,musteriAdi=?,musteriSoyadi=?,musteriMe slek=?musteriYasi=? WHERE musteriID=?)values('$musteriID','$musteriAdi','$mu steriSoyadi','$musteriMeslek'$musteriYasi')");
$sql->execute(array($musteriAdi,$musteriSoyadi,$musteri Meslek,$musteriYasi["musteriID"]));
if ($sql->rowCount() > 0 ) {
echo "güncelleme başarılı";
} else {
echo "hataolustu";
}
}
} else{
$sql = $db->prepare("INSERT INTO musteriler SET musteriID=?,musteriAdi=?,musteriSoyadi=?,musteriMe slek=?musteriYasi=? ");
$sql->execute([$musteriAdi,$musteriSoyadi,$musteriMeslek,$musteri Yasi]);
if ($sql->rowCount() > 0) {
echo "kayıt başarılı";
$file = file_get_contents("$resim");
$kayit = fopen('images/' . $resim_yol, "w+");
fwrite($kayit,$veri2);
fclose($kayit);
}
}
}
echo "
";
?>
config dosyası-------------------------------------------------------------------------------------------------
try {
$db = new PDO ("mysql:host=localhost;dbname=erdal", "root", "");
} catch (PDOException $e) {
print $e->getMessage();
}
?>
----- xml dosyam -----------------------------------------------------------------------------------