> For the complete documentation index, see [llms.txt](https://docs.layraweb.com.tr/merhaba/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.layraweb.com.tr/merhaba/php-tarafi/konular/veritabani-islemleri/veri-ekleme.md).

# Veri Ekleme

PHP ile veri tabanına veri ekleme işlemi için genellikle SQL `INSERT INTO` sorgusu kullanılır. Bu sorgu, veri tabanına yeni bir kayıt eklemek için kullanılır.

Veri eklemek için öncelikle veritabanı bağlantısını oluşturmanız gerekir. Bunun için `mysqli_connect()` veya `PDO` kullanabilirsiniz.

Ardından, `INSERT INTO` sorgusunu hazırlayın. Bu sorguda hangi tabloya, hangi sütunlara ve hangi değerlere veri ekleyeceğinizi belirtmelisiniz.

Son olarak, hazırlanan sorguyu `mysqli_query()` veya `PDO` fonksiyonu ile veri tabanına göndererek kaydı ekleyebilirsiniz.

İşlem sırası şu şekildedir:

1. Veritabanı bağlantısını oluşturun:

```php
$servername = "localhost";
$username = "kullaniciadi";
$password = "sifre";
$dbname = "veritabaniadi";

$conn = mysqli_connect($servername, $username, $password, $dbname);

if (!$conn) {
    die("Veritabanı bağlantısı başarısız: " . mysqli_connect_error());
}
```

2. `INSERT INTO` sorgusunu hazırlayın:

```php
$sql = "INSERT INTO kullanicilar (ad, soyad, email) VALUES ('John', 'Doe', 'johndoe@example.com')";
```

Bu örnekte, `kullanicilar` tablosuna `ad`, `soyad` ve `email` sütunlarına `John`, `Doe` ve `johndoe@example.com` değerleri ekleniyor.

3. Sorguyu veritabanına gönderin:

```php
if (mysqli_query($conn, $sql)) {
    echo "Yeni kayıt başarıyla eklendi";
} else {
    echo "Hata: " . $sql . "<br>" . mysqli_error($conn);
}
```

Bu örnekte, `mysqli_query()` fonksiyonu kullanılarak sorgu gönderiliyor. Eğer sorgu başarılı bir şekilde gerçekleştirilirse "Yeni kayıt başarıyla eklendi" mesajı gösterilecek, aksi takdirde hata mesajı görüntülenecektir.

Bu şekilde, PHP ile veritabanına yeni veri ekleyebilirsiniz.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.layraweb.com.tr/merhaba/php-tarafi/konular/veritabani-islemleri/veri-ekleme.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
