<?php 
	require_once('../Connections/conn_ama.php'); 
	include("../../../../../../functions/functions.php");    
	
	$curr_time = date("Y-m-d H:i:s");

	if (!isset($_SESSION)) {
	  session_start();
	}

	if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "save-new-gallery")) {

		$insertSQL = sprintf("INSERT INTO galleries (ah, gallerytitle, `gallerydesc`, dateAdded) VALUES (SHA1(MD5(RAND())), %s, %s, %s)",	
												//	GetSQLValueString(trim($_POST['ah']), "text"),
													GetSQLValueString($_POST['gallerytitle'], "text"),
													GetSQLValueString($_POST['gallerydesc'], "text"),
													GetSQLValueString($curr_time, "text"));

	  	$Result1 = mysqli_query($conn_ama, $insertSQL) or die(mysqli_error($conn_ama));
	  		$galleryID = mysqli_insert_id($conn_ama);
		  if($Result1){

		  	//List the uploaded news-article via the newsID
		    $query_rsArticle = "SELECT galleryID, ah FROM galleries WHERE galleryID = ".$galleryID;
				$rsArticle  = mysqli_query($conn_ama, $query_rsArticle) or die(mysqli_error($conn_ama));
				$row_rsArticle  = mysqli_fetch_assoc($rsArticle);
				$totalRows_rsArticle  = mysqli_num_rows($rsArticle);

			$reference = $row_rsArticle['ah'];
				if(isset($reference)){
				  echo "datasent:".$reference;
				}
			 }
			else{
				echo "notset";
			}
	}

 ?>