<?php
include "../db.php";

if (isset($_POST['state'])) {
    $state = mysqli_real_escape_string($con, $_POST['state']);
    $sql = "SELECT id FROM state WHERE name = '$state'";
    $result = mysqli_query($con, $sql);
    
    if ($row = mysqli_fetch_assoc($result)) {
        echo $row['id'];
    } else {
        echo '';
    }
}
?>