<?php session_start();  //Developed by ITechScripts
require 'include/announcements.php'; // ITECHBIDS Configuration File
require 'include/itechbids.php'; // Server compatibility Patch
$_REQUEST['user_name'];
function select_tag_string($name,$key,$array )
{
$temp=$key; 
$tag="<select name=\"$name\">";
foreach($array as $field)
{
if($temp==$field)
$tag=$tag. "<option value=\"$field\" selected>$field</option>";
else
$tag=$tag . "<option value=\"$field\">$field</option>";
}
$tag = $tag . "</select>";
return $tag;
}
function check($tab , $name)
{
while($row=mysql_fetch_array($tab))
{
  if(($row['user_name']==$name))
  {
    return  false;
  }
}
return true;
}
if(isset($_REQUEST['rate']))
{
   $user_name=$_REQUEST['user_name'];
   $rating=$_REQUEST['rating'];
  if($_SESSION['username']=="") 
  $rate_by = "Guest";
  else 
  $rate_by = $_SESSION['username'];
   $status=0;
   if($user_name=="")
   {
     $e_user_name="true";
	 $status=1;
   }
   if($rating=="-- Select Rate --")
   {
     $e_rating="true";
	 $status=1;
   }
   if($rate_by==$user_name)
   {
     $e_rate_by="true";
	 $status=1;
   }
   $query="select user_name from member_details ";
   $tab=mysql_query($query);
   if(check($tab, $user_name))
   {
     $e_user_name_found="true";
	 $status=1;
   }
   if($status==0)
   {
   switch($rating)
   {
     case "Excellent":
	                    $rate_value=5;
	                    break;   
	 case "Fair":
	                    $rate_value=3;
						break;
	 case "Good":
	                    $rate_value=2;
						break;
	 case "Bad": 
	                    $rate_value=0;
						break;
   }
   $query="insert into rate_value (user_name , rating_value , date , rated_by) values(";
   $query.= " '$user_name'  ,   '$rate_value'  ,   now()   ,   '$rate_by'  )";
   mysql_query($query);
   $flag="true";
   ?>
<?
require 'themes/rating1.php';
?>
   <?  
  }
 }
if($flag!="true")
{   
?>
<br>
<?
require 'themes/rating1.php';
?>
</body>
</html>
<?
}
?>