<?php
      include("connection.php");
      include("frames_header.php");
?>

<?php
$species=$_POST["name"];


if (ereg("^[A-Z][a-z]+\ [a-z\ ]+$", $species))
{
      //print "The entered name for this species is valide <br>";
      $requete="select * from \"SPECIES\" where \"NAME\"='$species'";
      $stmt = pg_query($c,$requete) or die("<strong>Error</strong> ".pg_last_error($c));
      if(!$row=pg_fetch_array($stmt))
      {
	pg_query($c,"begin");
            $requete="insert into \"SPECIES\" (\"NAME\") values ('$species')" or die("<strong>Error</strong> ".pg_last_error($c));
            $stmt1= pg_query($c,$requete);
            
	pg_query($c,"commit");

 
      			
      		print "<br><center><H1>$species INSERTED.</H1></center>";
      		print '<center><input name="Exit" type="button" value="-= Close window =-" onClick="javascript:self.close();"></center>';
 
      }
      else
      {
            print "<br><center><H1>A species with the same name already exists.</H1></center>";
            print '<center><input name="Exit" type="button" value="-= Close window =-" onClick="javascript:self.close();"></center>';
      }
      

}
else
{
      print "<br><center><H1>This name is not valid. use the latin denomination.</H1></center>";
}




?>

<?php
    include("frames_footer.php");
?>
