<?php session_start();  //Developed by ITechScripts
require 'include/announcements.php'; // ITECHBIDS Configuration File
require 'include/itechbids.php'; // ITECHBIDS Configuration File
$locheckuser=$_SESSION[username];
$locheckpass=$_SESSION[checkpass];
if((strlen($locheckuser)==0) || (strlen($locheckpass)==0))
{
echo '<meta http-equiv="refresh" content="0; url=index.php">';
exit();
} 
$lochecksql="select * from member_details where user_name='$locheckuser' and password='$locheckpass' and verified='yes' and approved='yes' and payment_status='yes'";
$locheckre=mysql_query($lochecksql);
if(mysql_num_rows($locheckre)==0)
{
echo '<meta http-equiv="refresh" content="0; url=index.php">';
exit();
} 
$user_id=$_SESSION[userid];
$cansave=$_POST[cansave];
if($cansave==1){
$femail=$_POST[femail];
$message=$_POST[message];
$bid_sql22="select * from tellafriend where email='$femail'";
$bid_res22=mysql_query($bid_sql22);
$totrec = mysql_num_rows($bid_res22);
if(mysql_num_rows($bid_res22)>0)
{
$errormes = "Unfortunately the email address in question has already been added";
}
if(mysql_num_rows($bid_res22)==0)
{
$bid_ins="insert into tellafriend(user_id,email,message,rdate) values($user_id,'$femail','$message',now())";
$ins=mysql_query($bid_ins);

$user_sql="select * from member_details where user_id=$user_id";
$user_result=mysql_query($user_sql);
$row=mysql_fetch_array($user_result);

$first=$row[first_name];
$last=$row[last_name];
$name = "$first $last";

	$admin="select * from genaralsettings where set_id=5";
	$admin_res=mysql_query($admin);
	$admin_row=mysql_fetch_array($admin_res);
	$mysitename=$admin_row[set_value];
	$admin="select * from genaralsettings where set_id=1";
	$admin_res=mysql_query($admin);
	$admin_row=mysql_fetch_array($admin_res);
	$mysiteadd=$admin_row[set_value];
	$admin="select * from genaralsettings where set_id=3";
	$admin_res=mysql_query($admin);
	$admin_row=mysql_fetch_array($admin_res);
	$mail_from=$admin_row[set_value];

$postmessage = "Greetings from $mysitename!
$name invited you to become a member and participate in $mysitename!
You are welcome to come and get acquainted with our site on the address: $mysiteadd
Your friend also left you the following message:
$message

Welcome!

Best regards

$mysitename";


$postsubject="$name invited you to become a member of $mysitename!";
$mail_to=$femail;

$headers  = "MIME-Version: 1.0\n";
$headers .= "From: ". $mail_from."\n";
$mail=mail($mail_to,$postsubject,$postmessage,$headers);
}
}



$bid_sql2="select * from tellafriend where user_id=$user_id";
$bid_res2=mysql_query($bid_sql2);

?>
<? require'themes/tellafriend.tpl'; 
?>  