<?php

	include ("frames_header.php"); 
	include ("connection.php");
	
    if ( (!isset($_SESSION["login"]))or(!isset($_SESSION["pass"])) ) {
	    print "<strong>you need to <a href=\"login.php\">login</a> as an authorised curator to proceed.</strong>";
	    print '</center></body></html>';
		return;
	}
			
	$gene_name = trim($_POST["gene"]);
	//VERIFY IF GENE_ID EXISTS...
	$khoueiry = "SELECT * FROM \"GENE\" WHERE \"NAME\"='".$gene_name."'";
	$stmt = pg_query($c,$khoueiry);
		
	if($row=pg_fetch_array($stmt)){    
	
		$khoueiry="INSERT INTO \"GENE_MOTIF\" (\"MOTIF_ID\", \"GENE_ID\") values (".$_POST["id"].",".$row["GENE_ID"].")";		
  		pg_query($c,$khoueiry) or die(pg_last_error($c));  		
  			
		echo '<SCRIPT LANGUAGE="JavaScript"> javascript:opener.location.reload(); self.close(); </script>';
		
	} else {
		echo '<p>Did not find gene '.$_POST["GENE"].' in the database</p>';	  
	}		     

	include ("frames_footer.php"); 

?>