<?php

session_start();

include "../config.php";
include "../header.php";
include "../style.php";

if( isset($_SESSION["ulogin"]) )
   	{  // members only stuff!

		include("navigation.php");
        include("../banners.php");
        echo "<font size=2 face='$fonttype' color='$fontcolour'><p><center>";
		echo "<H2><center><img src='images/ti-convert.png'></H2>";
       
        if($amount <= $commission and $amount>0) {
		
			mysql_query("UPDATE members SET points=points+".($amount*$pointrate).", commission=commission-'".$amount."' WHERE userid = '".$userid."'");
			
			
				mysql_query("INSERT INTO transactions VALUES ('".$userid."','Commission conversion for ".($amount*$pointrate)." points','".time()."','-$amount\$')");
			
				echo "<p><font face=\"Tahoma\" size=\"2\">You converted $amount\$ for ".($amount*$pointrate)." points. <a href=\"advertise.php\">Click here</a> to go back.</font></p>";
			
		} else {
			echo "<p><font face=\"Tahoma\" size=\"2\">You don't have enough commissions</font></p>";
		}
			

	echo "<br><br><br>";
  

 }

include "../footer.php";
mysql_close($dblink);
?>