Need some help with a contact form.

Ok, Thanks for any help you can give me.
My situation is this.

I currently have a website that shows a contact form to be able to comunicate to the author of an article.
The thing is that this contact form shows up even when there is no email filled out by the author of that article.
So what I need is that the contact form only shows up when there is an email stored for the article. I tried with the IF statement and failed miserably. I now this probably is easy for you guys, but I only have basic PHP knowledge.
here is a link for an article.
http://www.laguialongisland.com/400-room-available-in-farmingdale/
Sorry is in spanish but you can have an Idea of what I want to do.

The email if any. gets stored in the variable $to
I basically need something that if the $to variable is empty not to show the contact form at all but a message saying that this author does not have a email to be contacted instead.
Thanks again in advanced.

So far I have this:
[php]<?php
/* ---------------------------------------- CONTACT FORM --------------------------------
*/

$wpdb->hide_errors(); nocache_headers();

if(isset($_POST[‘do’]) && $_POST[‘do’] == “run”){

// SUBMITTION VERIFICATION
if($_POST['verify_val'] != $_POST['verify'] ){

	get_header();
	$edit_txt = $GLOBALS['_LANG']['_err21'];
	$SubmitErrorFound=1;
	
}else{

	check_admin_referer('DirectoryPressContactForm');
	$to = get_post_meta($post->ID, 'emailfield', true);
	$subject = "Su Anuncio en La guia Long Island ha recivido una pregunta";
	$headers = "Email: " . strip_tags($_POST['contact_email']) . "\r\n";
	$headers .= "Responder: " . strip_tags($_POST['contact_email']) . "\r\n";
	$headers .= "Return-Path: " . strip_tags($_POST['contact_email']) . "\r\n";
	$headers .= "MIME-Version: 1.0\r\n";
	$headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n";
	
	if(get_option("ccemail") !=""){
		$headers .= 'Cc: '.get_option("ccemail").'' . "\r\n";
	}
	if(get_option("bccemail") !=""){
		$headers .= 'Bcc: '.get_option("bccemail").'' . "\r\n";
	}

	
	$message = "<p> =============== Su Anuncio en La Guia Long Island ha recivido una pregunta ==================
				<p> Nombre : " . strip_tags($_POST['contact_name']) . "
				<p> Direccion de Email : " . strip_tags($_POST['contact_email']) . "
				<p> Telefono : " . strip_tags($_POST['contact_phone']) . "
				<p> Mensaje : " . strip_tags($_POST['contact_comment']) . "";
	apply_filters( 'wp_mail_content_type', "text/html" );
	wp_mail( $to, $subject, $message, $headers);
	

	$completed =1;
	
	get_header();
}

}else{

get_header();

}

?>

<?php if(file_exists($PPT->FilterPath()."/wp-content/themes/directorypress/themes/".$GLOBALS['premiumpress']['theme'].'/sidebar1.php')){ include($PPT->FilterPath()."/wp-content/themes/directorypress/themes/".$GLOBALS['premiumpress']['theme'].'/sidebar1.php'); } ?>

Llena el formulario para contactar el anunciante

<?php if(isset($edit_txt)){ print "
".$GLOBALS['_LANG']['_err23']."
".$edit_txt."
"; } ?> <?php if(isset($completed)){ ?>

<?php echo $GLOBALS['_LANG']['_c16'] ?>


Su mensaje a sido enviado al anunciante satisfactoriamente


<?php echo $GLOBALS['_LANG']['_c18'] ?>

<?php }else{ ?>
form div{clear:none;margin-bottom:0;vertical-align:text-top;padding:0;} #form{padding:10px; width:560px; margin-bottom:30px; } #form1a{width:250px; float:left; display:inline;} #form2b{margin-left:20px; width:200px; float:left; display:inline;} #form p{color:#333333; font-size:14px;} .enq_form{background-color:#fff; border: 2px solid #cccccc; font-family:Arial, Helvetica, sans-serif; font-size:12px; color:#666666; padding:5px; margin-top:5px; width:200px} .send_button{width:107px; height:29px; background: #666666; border:0; color:white; cursor:pointer; margin-top:30px; font-weight:bold; font-family: Arial, Helvetica, sans-serif; }
	<script>

	function CheckCallBackForm()
	{

		var email = document.getElementById("email");
		var phone = document.getElementById("phone"); 
		var comment = document.getElementById("comment1");

		if(email.value.indexOf('@') == -1 || email.value.indexOf('.') == -1)
		{
			alert('Por favor introduzca una direccion de Email valida.');
			email.focus();
			email.select();
			return false;
		}

		if(phone.value == '')
		{
			alert('Por favor introduzca su nombre.');
			phone.focus();
			return false;
		}

		if(comment.value == '')
		{
			alert('Por favor introduzca su mensaje.');
			comment.focus();
			return false;
		}

		// Everything is OK
		return true;
	}

</script>
<?php wp_nonce_field('DirectoryPressContactForm') ?>
<div id="form1a"> 
	<p><strong><?php echo $GLOBALS['_LANG']['_c3'] ?>:</strong> *<br /><input type="text" id="name" name="contact_name" class="enq_form" value="<?php if(isset($_POST['do'])){ echo strip_tags($_POST['contact_name']); } ?>" /></p>
	<p><strong><?php echo $GLOBALS['_LANG']['_c4'] ?>:</strong> *<br />  <input type="text" id="phone" name="contact_phone" class="enq_form" value="<?php if(isset($_POST['do'])){ echo strip_tags($_POST['contact_phone']); } ?>" /></p>
	<p><strong><?php echo $GLOBALS['_LANG']['_c5'] ?>:</strong> *<br />   <input type="text" name="contact_email" id="email" class="enq_form" value="<?php if(isset($_POST['do'])){ echo strip_tags($_POST['contact_email']); } ?>" /></p>
    </div>

<div id="form2b">
<p><?php echo $GLOBALS['_LANG']['_c11'] ?>:<br />  <textarea id="comment1" name="contact_comment" cols="30" rows="6" class="enq_form"><?php if(isset($_POST['do'])){ echo strip_tags($_POST['contact_comment']); } ?></textarea></p>
<p><br />
</p>
	<?php
	$string =  $GLOBALS['_LANG']['_err25'];
	$v_a = rand(1, 30);
	$v_b = rand(1, 30);
	$v_string  = str_replace("%a",$v_a,str_replace("%b",$v_b,$string));
	?> 
	<label for="title"><?php echo $v_string; ?></label>
    <input type="text" class="adfields" name="verify" size="15" maxlength="10" style="width:50px;" />				
    <p><?php echo $GLOBALS['_LANG']['_err26']; ?></p>
    <input type="hidden" name="verify_val" value="<?php echo $v_a+$v_b; ?>" />
    
<input class="send_button" type="submit" value="<?php echo $GLOBALS['_LANG']['_c15'] ?>" name=""/>


<?php } ?>
 
 
 
<?php }else{ print "

"; } ?>[/php]

Ok, what you need to do is firstly have the user id of the members page that you are looking at.

Then you can do something like this:
[php]
//database info

$query = mysql_query(“SELECT email FROM members WHERE id=’$id’”);
while($row = mysql_fetch_assoc($query))
{
$email = $row[‘email’];

	}

if($email=’’)
{
//no contact form
}

else{
//contact form code
}

[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service