<?php
include("../Connections/courier.php");
try{
    if(isset($_REQUEST["term"])){
        $sql = "SELECT * FROM region WHERE region LIKE :term";
        $stmt = $conn->prepare($sql);
        $term = $_REQUEST["term"] . '%';
        // bind parameters to statement
        $stmt->bindParam(":term", $term);
        // execute the prepared statement
        $stmt->execute();
        if($stmt->rowCount() > 0){
            while($row = $stmt->fetch()){
                echo "<p>" .$row["region"]. "</p>";
            }
        } else{
            echo "<p>No matches found</p>";
        }
    }
} catch(PDOException $e){
    die("ERROR: Could not able to execute $sql. " . $e->getMessage());
}

// Close statement
unset($stmt);

// Close connection
unset($conn);
?>