<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<title>InsertNewOwner PHP Page</title>
		<style type="text/css">
			h1 {text-align: center; color: blue}
			h2 {font-family: Ariel, sans-serif; text-align: left; color: blue}
			p.footer {text-align: center}
			table.output {font-family: Ariel, sans-serif}
		</style>
	</head>
	<body>
	<?php
		// Get connection
		$DSN = "GG";
                $User = "GG-User";
                $Password = "GG-User+password";
    
                $Conn = odbc_connect($DSN, $User, $Password);	
	
		// Test connection
		if (!$Conn)
			{
				exit ("ODBC Connection Failed: " . $Conn);
			}
		// Create short variable names
		$OwnerName = $_POST["OwnerName"];
		$OwnerEmailAddress = $_POST["OwnerEmailAddress"];
		$OwnerType = $_POST["OwnerType"];
				
		// Create SQL statement to INSERT new data
		$SQLINSERT = "INSERT INTO OWNER ";
		$SQLINSERT .= "VALUES('$OwnerName', ";
		$SQLINSERT .= "'$OwnerEmailAddress', '$OwnerType')";
	
		// Execute SQL statement
		$Result = odbc_exec($Conn, $SQLINSERT);
	
		// Test existence of result
		echo "<h1>
				The Garden Glory OWNER Table
			</h1>
			<hr />";
		if ($Result){	
			echo "<h2>
				New Owner Added:
			</h2>
			<table>
				<tr>";
				echo "<td>OwnerName:</td>";
				echo "<td>" . $OwnerName . "</td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td>OwnerEmailAddress:</td>";
				echo "<td>" . $OwnerEmailAddress . "</td>";
				echo "</tr>";
				echo "<tr>";
				echo "<td>OwnerType:</td>";
				echo "<td>" . $OwnerType . "</td>";
				echo "</tr>";
				echo "</table><br /><hr />";
			}
			else {
				exit ("SQL Statement Error: " . $SQL);
			}
			
		// Create SQL statement to read OWNER table data
    	$SQL = "SELECT * FROM OWNER";
 
    	// Execute SQL statement
    	$RecordSet = odbc_exec($Conn,$SQL);
    
    	// Test existence of recordset
    	if (!$RecordSet)
	    	{
	        	exit ("SQL Statement Error: " . $SQL);
	    	}
	?>
	    <!--  Page Headers -->
	    <h2>
	        OWNER
		</h2>
	<?php	  
		// Table headers
	    echo "<table class='output' border='1'>
	    		<tr>
	    			<th>OwnerName</th>
	    			<th>OnwerEmailAddress</th>
	    			<th>OnwerType</th>
	    		</tr>";
	    
	    // Table data
	    while($RecordSetRow = odbc_fetch_array($RecordSet))
	    	{
	    	echo "<tr>";
	    	echo "<td>" . $RecordSetRow['OwnerName'] . "</td>";
	    	echo "<td>" . $RecordSetRow['OwnerEmailAddress'] . "</td>";
	    	echo "<td>" . $RecordSetRow['OwnerType'] . "</td>";
	    	echo "</tr>";
	    	}
	    echo "</table>";

	    // Close connection
		odbc_close($Conn);
	?>
		<br />
		<hr />
		<p class="footer">	
			<a href="../GG/index.html">
				Return to Garden Glory Home Page
			</a>
		</p>
		<hr />
	</body>
</html>
