• Dastur kodlari
  • $servername = "localhost"




    Download 432,44 Kb.
    Sana28.05.2024
    Hajmi432,44 Kb.
    #256021
    Bog'liq
    Axmedjanov Ilyosbek


    O‘ZBEKISTON RESPUBLIKASI
    RAQAMLI TEXNOLOGIYALAR VAZIRLIGI
    MUHAMMAD AL-XORAZMIY NOMIDAGI TOSHKENT AXBOROT TEXNOLOGIYALARI UNIVERSITETI NURAFSHON FILIALI

    “Kompyuter injiniringi” fakulteti


    Guruh nomi: 210-22


    F.I.SH: Axmedjanov Ilyosbek
    Fan: Web dasturlashga kirish


    Dastur kodlari:




    Document




    $servername = "localhost";
    $username = "root"; // Sizning MySQL foydalanuvchi nomingiz
    $password = ""; // Sizning MySQL parolingiz
    $dbname = "students";
    // MySQL bilan ulanish
    $conn = new mysqli($servername, $username, $password, $dbname);
    // Ulanish holatini tekshirish
    if ($conn->connect_error) {
    die("Ulanish xatosi: " . $conn->connect_error);
    }
    // Formadan ma'lumotlar qabul qilish va SQL jadvalga qo'shish
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
    $first_name = $_POST['first_name'];
    $last_name = $_POST['last_name'];
    $email = $_POST['email'];
    $password = password_hash($_POST['password'], PASSWORD_BCRYPT);
    $avatar = $_FILES['avatar']['name'];
    // Avatarni yuklash
    if (!empty($avatar)) {
    $target_dir = "./img/Ilyosbek.jpg";
    $target_file = $target_dir . basename($_FILES["avatar"]["name"]);
    move_uploaded_file($_FILES["avatar"]["tmp_name"], $target_file);
    }
    $sql = "INSERT INTO users (first_name, last_name, email, password, avatar)
    VALUES ('$first_name', '$last_name', '$email', '$password', '$avatar')";
    if ($conn->query($sql) === TRUE) {
    echo "Yangi yozuv muvaffaqiyatli qo'shildi";
    } else {
    echo "Xatolik: " . $sql . "
    " . $conn->error;
    }
    }
    // Ma'lumotlarni olish
    $sql = "SELECT * FROM users";
    $result = $conn->query($sql);
    $conn->close();
    ?>






    REGISTRATSIYA
























    Talabalar














    num_rows > 0): ?>
    fetch_assoc()): ?>
















    # First Last Email Image Url Actions




    Ma'lumotlar mavjud emas



    Download 432,44 Kb.




    Download 432,44 Kb.