<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
   	<title>InsertNewSeminar 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 = "HSD";
            $User = "HSD-User";
            $Password = "HSD-User+password";
    
            $Conn = odbc_connect($DSN, $User, $Password);	
	
            // Test connection
            if (!$Conn)
		{
		exit ("ODBC Connection Failed: " . $Conn);
		}
        
            // Create short variable names
            $SeminarDate = $_POST["SeminarDate"];
            $SeminarTime = $_POST["SeminarTime"];
            $Location = $_POST["Location"];
            $SeminarTitle = $_POST["SeminarTitle"];
                
            // $SeminarDate = filter_input($_POST, 'SeminarDate', FILTER_SANITIZE_SPECIAL_CHARS);
            // $SeminarTime = filter_input($_GET, 'SeminarTime', FILTER_SANITIZE_SPECIAL_CHARS);
            // $Location = filter_input($_GET, 'Location', FILTER_SANITIZE_SPECIAL_CHARS);
            // $SeminarTitle = filter_input($_GET, 'SeminarTitle', FILTER_SANITIZE_SPECIAL_CHARS);
            
            // Create SQL statement to INSERT new data
            $SQLINSERT = "INSERT INTO SEMINAR ";
            $SQLINSERT .= "VALUES('$SeminarDate', '$SeminarTime', ";
            $SQLINSERT .= "'$Location', '$SeminarTitle')";    
            // Execute SQL statement
            $Result = odbc_exec($Conn, $SQLINSERT);
	
            // Test existence of result
            echo "<h1>
		The Heather Sweeney Designs SEMINAR Table
		</h1>
		<hr />";
            if ($Result) {
                echo "<h2>
                    New Seminar Added:
                    </h2>
                    <table>
			<tr>";
                    	echo "<td>Seminar Date:</td>";
			echo "<td>" . $SeminarDate . "</td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td>Seminar Time:</td>";
			echo "<td>" . $SeminarTime . "</td>";
			echo "</tr>";
			echo "<tr>";
			echo "<td>Location:</td>";
			echo "<td>" . $Location . "</td>";
			echo "</tr>";
			echo "<td>Seminar Title:</td>";
			echo "<td>" . $SeminarTitle . "</td>";
			echo "</tr>";
                    echo "</table><br /><hr />";
                    }
		 else {
                    exit ("SQL Statement Error One: " . $SQL);
                    }
			
            // Create SQL statement to read SEMINAR table data
            $SQL = "SELECT * FROM SEMINAR";
 
            // Execute SQL statement
            $RecordSet = odbc_exec($Conn,$SQL);
    
            // Test existence of recordset
            if (!$RecordSet)
	    	{
	       	exit ("SQL Statement Error Two: " . $SQL);
	    	}	
            // Table headers
	    echo "<table class='output' border='1'>
	    	<tr>
                    <th>SeminarDate</th>
                    <th>SeminarTime</th>
                    <th>Location</th>
                    <th>SeminarTitle</th>
	    	</tr>";
	    
	    // Table data
	    while($RecordSetRow = odbc_fetch_array($RecordSet))
	    	{
	    	echo "<tr>";
	    	echo "<td>" . $RecordSetRow['SeminarDate'] . "</td>";
	    	echo "<td>" . $RecordSetRow['SeminarTime'] . "</td>";
	    	echo "<td>" . $RecordSetRow['Location'] . "</td>";
	    	echo "<td>" . $RecordSetRow['SeminarTitle'] . "</td>";
	    	echo "</tr>";
	    	}
	    echo "</table>";
	    	
            // Close connection
            odbc_close($Conn);
    ?>
            <br />
            <hr />
            <p class="footer">	
		<a href="../HSD/index.html">
                    Return to Heather Sweeney Designs Home Page
		</a>
            </p>
            <hr />
    </body>
</html>

