<?php
	include('/var/www/html/uclit/protected/common/login/check.php');
	include('/var/www/html/uclit/protected/common/css_login/css_head2.php');
	include('/var/www/html/uclit/protected/connections/db_work.php'); 

	if(isset($_POST['type']) && $_POST['type'] == "edit" && $_POST['id'] != "") 
	{
		$id = $_POST['id'];
		$name = $_POST['cname'];
		$des = $_POST['cdes'];
		$prereq = $_POST['cprereq'];
		$ques = $_POST['cques'];
		$surv = $_POST['csurvey'];
		echo" Survey 1 - $surv";
		mysql_select_db($database_workshop, $sqlConn) or die("Could not select database");
		$sqlQuerry = "UPDATE workshop_detail SET w_name='$name', w_description='$des', w_prereq='$prereq', w_pre_question='$ques', w_survey='$surv' WHERE w_id='$id'";
		$QuerryResult = mysql_query($sqlQuerry) or die("UPDATE query failed");
		
		echo "Updated workshop: $name successfull<br />
			<a href='list_administer.php'>Administer List</a>
			<script type='text/javascript'>
					window.location='http://ul.uc.edu/uclit/protected/workshop/list_administer.php';
				</script>	
			";
	}
	else if( isset($_POST['type']) && $_POST['type'] == "add")
	{
		$name = $_POST['cname'];
		$des = $_POST['cdes'];
		$prereq = $_POST['cprereq'];
		$ques = $_POST['cques'];
		$surv = $_POST['csurvey'];
		echo" Survey 2 - $surv";
		if($prereq != "")
			$ques = "1";
		else
			$ques = "0";	
		mysql_select_db($database_workshop, $sqlConn) or die("Could not select database");
		$sqlQuerry = "INSERT INTO workshop_detail(w_name, w_description, w_prereq, w_pre_question, w_survey) values('$name','$des','$prereq','$ques','$surv')";
		$QuerryResult = mysql_query($sqlQuerry) or die("INSERT query failed");
		echo "Added workshop: $name successfull<br />
			<a href='list_administer.php'>Administer List</a>
			<script type='text/javascript'>
					window.location='http://ul.uc.edu/uclit/protected/workshop/list_administer.php';
			</script>
			
			";
	}
	else
	{
		echo "Invalid entry into this form.  Please return to <a href='list_administer.php'>Administer List</a><br />";
	}
	include('/var/www/html/uclit/protected/common/css_login/css_foot2.php'); 
	?>
