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

print "<title>ANISEED CURATOR - Add an article </title>";

?>



<?

$pmid=$_POST["pmid"];
$title=$_POST["title"];
$paper=$_POST["paper"];
$author=$_POST["author"];
$comments=$_POST["comments"];
$url=$_POST["url"];



pg_query($c,"begin");

if ((strlen($url)>0) && (strlen($comments)>0)) $requete="INSERT INTO \"ARTICLE\" (\"ARTICLE_ID\",\"PUBMED_ID\",\"TITLE\",\"PAPER\",\"AUTHORS\",\"URL\",\"COMMENTS\") values (nextval('\"S_ARTICLE_ID\"'),'$pmid','$title','$paper','$author','$url','$comments')";
else if ((strlen($url)>0) && (strlen($comments)==0)) $requete="INSERT INTO \"ARTICLE\" (\"ARTICLE_ID\",\"PUBMED_ID\",\"TITLE\",\"PAPER\",\"AUTHORS\",\"URL\") values (nextval('\"S_ARTICLE_ID\"'),'$pmid','$title','$paper','$author','$url')";
else if ((strlen($url)==0) && (strlen($comments)>0)) $requete="INSERT INTO \"ARTICLE\" (\"ARTICLE_ID\",\"PUBMED_ID\",\"TITLE\",\"PAPER\",\"AUTHORS\",\"COMMENTS\") values (nextval('\"S_ARTICLE_ID\"'),'$pmid','$title','$paper','$author','$comments')";
else if ((strlen($url)==0) && (strlen($comments)==0)) $requete="INSERT INTO \"ARTICLE\" (\"ARTICLE_ID\",\"PUBMED_ID\",\"TITLE\",\"PAPER\",\"AUTHORS\") values (nextval('\"S_ARTICLE_ID\"'),'$pmid','$title','$paper','$author')";

pg_query($c,$requete) or die("Insertion Failed !! Please restart the process again and please have a look on your data that might be wrong !");


pg_query($c,"commit");



$requete="SELECT currval('\"S_ARTICLE_ID\"') as \"CUR\"";
$stmt=pg_query($c,$requete);
$row=pg_fetch_array($stmt);
$INSERT=$row["CUR"];

?>




<center><h3>Insertion done  ( Article ID: <? print $INSERT; ?> )</h3></center>

<br><br>


<center>Go to the Article card page <a href="edit-article.php?id=<?print $INSERT;?>">Here</a></center>
<br>


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