<?php
$name = $_POST["name"];
$pass = $_POST["pass"];
$text = $_POST["data"];

$servername = "localhost";
    $username = "mtplusteam_mtplusteam";
    $password = "R{Kfeq+_qICNX=DB";
    $dbname = "mtplusteam_server";

$conn = new mysqli($servername, $username, $password, $dbname);

if($conn->connect_error){
    echo "error-admin";
}

$sql = "SELECT * FROM `dhtml` WHERE name='$name'";

$result = $conn->query($sql);

if($result->num_rows > 0){
    
    $row = $result->fetch_assoc();

    $pass2 = $row["pass"];
        
    if($pass2 == $pass){
        $my_file = fopen($name.'.html', 'w');
        fwrite($my_file, "$text");
        fclose($my_file);
        echo "ok";
    }
    else{
        echo "error-user";
    }
}
else{
    echo "error-user";
}

$conn->close();
?>