Bir kayıt sayfası yapmaya çalışıyorum ve sweetalert teki gibi kayıt başarılı şeklinde uyarı yazdırmak istiyorum ama ne yaptı isem maalesef kayıt oluyor onda sorun yok ama uyarıyı ekrana yazdirmiyor kod aşağıda ki gibi bilgisi olan nerede hata yapıyorum bilgilendirebilirse sevinirim .
<?php
// Veritabanı bağlantısı
$db_host = 'localhost';
$db_user = 'root;
$db_pass = 'x';
$db_name = x';
$conn = new mysqli($db_host, $db_user, $db_pass, $db_name);
if ($conn->connect_error) {
die("Veritabanına bağlanırken hata: " . $conn->connect_error);
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$username = $_POST["username"];
$email = $_POST["email"];
$password = password_hash($_POST["password"], PASSWORD_DEFAULT); //
// Veritabanına kullanıcıyı ekle
$sql = "INSERT INTO users (username, email, password) VALUES ('$username', '$email', '$password')";
if ($conn->query($sql) === TRUE) {
echo '<script>
new Noty({
text: "Kayıt başarıyla tamamlandı",
type: "success",
layout: "topRight",
timeout: 3000
}).show();
</script>';
} else {
echo '<script>
new Noty({
text: "Hata oluştu: ' . $conn->error . '",
type: "error",
layout: "topRight",
timeout: 3000
}).show();
</script>';
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Kayıt Sayfası</title>
<!-- Noty CSS -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/noty@3.1.4/lib/noty.css">
</head>
<body>
<h2>Kayıt Ol</h2>
<form method="post" action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>">
<label for="username">Kullanıcı Adı:</label>
<input type="text" id="username" name="username" required><br>
<label for="email">E-posta:</label>
<input type="email" id="email" name="email" required><br>
<label for="password">Şifre:</label>
<input type="password" id="password" name="password" required><br>
<input type="submit" value="Kayıt Ol">
</form>
<script src="https://code.jquery.com/jquery-3.6.4.min.js"></script>
<!-- Noty JavaScript -->
<script src="https://cdn.jsdelivr.net/npm/noty@3.1.4/lib/noty.js"></script>
</body>
</html>
<?php
$conn->close();
?>
```