<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta name="description" content="MIT CSAIL Film History of AI Database">
<meta name="keywords" content="CSAIL, MIT, MIT CSAIL, Film History of AI, History of AI, AI, MIT AI, Artificial Intelligence">
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>MIT Film History of Artificial Intelligence: Submit Comment</title>
<link href="pagedefaults.css" rel="stylesheet" type="text/css">

</head>

<body>

<?php

if(!$_GET['comment']) {	
	$filename = $_GET['url'];
	$title = $_GET['title'];
	echo ('You forgot to enter a comment!  
		<form action="commentpost.php" name="commentpost" method="post">
		<input type="hidden" name="filename" value="'.$filename.'">
		<input type="hidden" name="title" value="'.$title.'">
		<font color="#CC0033" size="3"><input name="submit" type="submit" value="Go back and try again"/></font>
		</form><br>');
	}
if(!$_GET['name']) {
	$filename = $_GET['url'];
	$title = $_GET['title'];
	echo ('You forgot to enter a name! 
		<form action="commentpost.php" name="commentpost" method="post">
		<input type="hidden" name="filename" value="'.$filename.'">
		<input type="hidden" name="title" value="'.$title.'">
		<font color="#CC0033" size="3"><input name="submit" type="submit" value="Go back and try again"/></font>
		</form><br>');
	}
elseif(!$_GET['filename']) {
	echo ('Trouble!  The script encountered an error.  Wait a minute and try again, or contact the webmaster. ');
	}	
elseif(!$error) {	
	$filename = $_GET['filename'];
	$title = $_GET['title'];
	$name = $_GET['name'];
	$comment = $_GET['comment'];
													
	//Database section!  Add a new comment field to the film's slice of the database.
	
	//extract date
	$day = date(D);
	$date = date(j);
	$month = date(F);
	$hour = date(H);
	$minutes = date(i);
	$timestamp = "At ".$hour.":".$minutes." on ".$day.", ".$month." ".$date.",  ".$name." wrote:"; 

	$newcomment = $timestamp."\n<br>".$comment."\n<br>\n<br>";
	

 print $newcomment."<br>";

 }

 



/*
	$db = @mysql_connect("mysql.csail.mit.edu","filmsai","filmsAI+3456") or die("Whoops!  Couldn't connect to the database \
server.  Try again in a minute or contact the webmaster.");
	@mysql_select_db("filmsAI",$db) or die("Whoops!  Couldn't select database.  Try again in a minute or contact the webmaster.");

	$result = @mysql_query("SELECT * FROM `comments` WHERE `id`=0",$db);
	$resultno = mysql_num_fields($result);
	//print $resultno."<br>";
	//$lastno = $resultno - 2;
	//for ($i = 1; $i <= $lastno; $i++) {
	//		printf("comment%03s\n<br>",  $i);
	//		}
	$newno = $resultno - 1;
	$newcommentname = sprintf("comment%03s\n<br>", $newno);

				
	@mysql_query("ALTER TABLE `comments` ADD $newcommentname TEXT NOT NULL",$db) or die("Whoops!  The script failed to set the new comments.  Try again in a minute or contact the webmaster.");
	@mysql_query("ALTER TABLE `comments` ADD FULLTEXT ('$newcommentname')",$db) or die("Foo!  No good.");
	@mysql_query("INSERT INTO `comments` (`id`, `filename`, `$newcommentname`) VALUES (

	$number = substr($filename,0,2);
	
	echo ('<div align="center">
	Thanks for submitting your comments about "'.$title.'".  
	<br>Return to 
	<a href="http://projects.csail.mit.edu/films/">the main page</a>
	 or go back to 
	<a href="http://projects.csail.mit.edu/films/aifilmsdynamicPage6.php?reel%23='.$number.'>the film\'s page. 
	</div>
	');
	}
	
else
	echo ('The script encountered an unknown error.  Try again in a minute or contact the webmaster.');
	
?>


<?php
//
 //       $db=@mysql_connect("mysql.csail.mit.edu","filmsai","filmsAI+3456") or die("Whoops!  Couldn't connect to the database \
//server.  Try again in a minute or contact the webmaster.");
  //      @mysql_select_db("filmsAI",$db) or die("Whoops!  Couldn't select database.  Try again in a minute or contact the webm\
//aster.");
//
//        $result = @mysql_query("SELECT * FROM `comments` WHERE `id`=0",$db);
 //       $resultno = mysql_num_fields($result);
//        print $resultno."<br>";
//        $lastno = $resultno - 2;
//        for ($i = 1; $i <= $lastno; $i++) {
//                printf("comment%03s\n<br>",  $i);
//                }
//        $newno = $resultno - 1;
//        $nextcommentname = sprintf("comment%03s\n<br>", $newno);
//        print $nextcommentname;
?>
*/

?>
</body>
</html>