Thanks @user141080 I had the table_name declared wrong. I also missing the ” around the ‘$postcode’, which you do by adding an extra ‘at the end of the where clause and .”‘” after the variable.
The code below works now.
<?php
/*-------------------------------------------------*/
/*-------------Check Postcode -----------------*/
/*-------------------------------------------------*/
global $wpdb;
$table_name = $wpdb->prefix.'vw_postcode_checker';
if (!empty($_POST[postcode]))
{
$postcode = $_POST[postcode];
$entry = $wpdb->get_row( "SELECT * FROM ".$table_name." WHERE postcode="" . $postcode . """);
if (isset($entry))
{
$town = $entry->town;
$county = $entry->county;
$your_area = $town . ", " . $county;
$confirmed = "Congratulations, we are delivering to " . $your_area;
echo $confirmed;
}
else
{
$notconfirmed = "Sorry, we are not delivering to your area at this time.";
echo $notconfirmed;
}
}
?>