<?php
$user = $_POST["username"];
$pass = $_POST["password"];

$servername90 = "localhost";
    $username90 = "mtplusteam_mtplusteam";
    $password90 = "R{Kfeq+_qICNX=DB";
    $dbname90 = "mtplusteam_server";



$connection90 = new mysqli($servername90, $username90, $password90, $dbname90);

if ($connection90->connect_error) {
    echo 'مشکلی به وجود امد.';
    exit;
}

$username90 = $_POST["name"];
$pass = $_POST["password"];

if (!isset($_POST["name"]) || !isset($_POST["password"])) {
    header('Location: https://tackserver.top/test404');
    exit;
} else {
    $dataSql90 = "SELECT * FROM dhtml WHERE name = '$username90'";
    $result90 = $connection90->query($dataSql90);

    if ($result90->num_rows > 0) {
        $row90 = $result90->fetch_assoc();
        echo "Error404";
        exit;
    } else {
        session_start();

        define('DBUSER', 'mtplusteam_mtplusteam');
        define('DBPASS', 'R{Kfeq+_qICNX=DB');
        define('DBHOST', 'localhost');
        define('DBNAME', 'mtplusteam_server');

        try {
            $connection = new PDO("mysql:host=".DBHOST.";dbname=".DBNAME, DBUSER, DBPASS);
        } catch (PDOException $e) {
            exit("خطایی رخ داده (" . $e->getMessage() . ")");
        }

        $username5 = $_POST['username'];
        $password5 = $_POST['upassword'];



        $query = $connection->prepare("SELECT * FROM login WHERE username=:username");
        $query->bindParam("username", $username5, PDO::PARAM_STR);
        $query->execute();

        $result = $query->fetch(PDO::FETCH_ASSOC);

        if (!$result) {
            echo '<p class="error">نام سرور یا رمز اشتباه</p>';
            exit;
        } else {
            if ($password5 == $result["pass"]) {
                $username_get = $_POST['username'];
                $password_get = $_POST['password'];
                $name_get = $_POST['name'];
                $data = "s server";
                $sql_get = "INSERT INTO dhtml (username, name, pass) VALUES ('$username_get','$name_get','$password_get')";

                $file = fopen($name_get . '.html', 'w');
                fwrite($file, $data);
                fclose($file);
                echo "ok";
                if ($connection->query($sql_get) === TRUE) {
                    
                }
                exit;
            }
        }
    }
}
?>