<?php

include_once __DIR__ . '/../secrets.php';

include '../db_connect.php';

$type = $_POST[ 'type' ];
$text = $_POST[ 'text' ];
$postid = $_POST[ 'postid' ];
$key = $_POST[ 'key' ];

$security_key = decrypData($key);

if ($security_key === false) {
    echo 'Invalid encryption data';
    exit;
}

if ($security_key == SECURITY_KEY_PLAIN) {

    $con = dbConnect();

    $sql = "UPDATE post_table SET text = '$text', type = '$type' WHERE id = '$postid'";
    $result = mysqli_query ( $con, $sql );

    if ( $result ) {
        echo 'Successfully';
    } else {
        echo'Qury Error';
    }

} 

?>