• 01-05-2022, 23:31:54
    #1
    Sorun Giderildi
  • 01-05-2022, 23:34:44
    #2
    Hocam pdo ile veritabanı bağlantısı yapmışsınız fakat veri eklerken mysqli kullanıyorsunuz yanlış bilmiyorsam şöyle yapmanız gerek.

    <?php
    
    include '../inc/config.php';
    
    error_reporting(0);
    
    session_start();
    
    if (isset($_SESSION['ad'])) {
    header("Location: ../anasayfa.php");
    }
    
    if (isset($_POST['submit'])) {
    $ad = $_POST['ad'];
    $soyad = $_POST['soyad'];
    $email = $_POST['email'];
    $password = md5($_POST['password']);
    $cpassword = md5($_POST['cpassword']);
    
    if ($password == $cpassword) {
    $sql = "SELECT * FROM users WHERE email='$email'";
    $result = mysqli_query($conn, $sql);
    if (!$result->num_rows > 0) {
    $sql = "INSERT INTO users (ad, soyad, email, password)
    VALUES ('$ad', '$soyad', '$email', '$password')";
    $result = $conn->query($sql);
    if ($result) {
    echo "<script>alert('Wow! User Registration Completed.')</script>";
    $ad = "";
    $soyad = "";
    $email = "";
    $_POST['password'] = "";
    $_POST['cpassword'] = "";
    } else {
    echo "<script>alert('Woops! Something Wrong Went.')</script>";
    }
    } else {
    echo "<script>alert('Woops! Email Already Exists.')</script>";
    }
    
    } else {
    echo "<script>alert('Password Not Matched.')</script>";
    }
    }
    
    ?>