<?php
if ( ! defined( 'ABSPATH' ) ) {
  exit; // Exit if accessed directly
}
?>
<?php get_header(); ?>
<?php $template_url = get_bloginfo ( 'template_url' ) . '/'; ?>
<?php 
//to check if there is a post regarding the url access the page
if (have_posts ()) :
  the_post(); 
endif;
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID), 'thumbnail' );
if($url != "")
{
$img = $url; 
}else{
$img = $template_url."images/contactbg.jpg"; 
} 
?>
eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
<?php get_footer();?>