<?php

include '../db_connect.php';

$id = $_POST[ 'id' ];
$name = $_POST[ 'name' ];
$phone = $_POST[ 'phone' ];
$email = $_POST[ 'email' ];
$gender = $_POST[ 'gender' ];
$birthdate = $_POST[ 'birthdate' ];
$country = $_POST[ 'country' ];
$key = $_POST[ 'key' ];

$security_key = decrypData( $key );

if ( $security_key == 'Jobayer121415' && strlen( $id )>0 ) {

    $con = dbConnect();

    $sql = "UPDATE singup_table SET name = '$name', phone = '$phone', email = '$email', gender = '$gender', birthdate = '$birthdate', country = '$country' WHERE id = '$id'";
    $result = mysqli_query ( $con, $sql );

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

} else {
    echo json_encode( [ 'error' => 'Invalid key or password' ] );
}

function decrypData ( $text ) {

    $encoded = $text;
    $decoded = base64_decode( $encoded );
    $decrypted = openssl_decrypt( $decoded, 'AES-128-ECB', '0175526800812345', OPENSSL_RAW_DATA );
    return $decrypted;

}

?>