<!DOCTYPE html>
<html>
<head>
	<?php include('include/head.php'); ?>
</head>
<body>
	<?php include('include/header.php'); ?>
	<?php include('include/sidebar.php'); ?>
	<div class="main-container">
		<div class="pd-ltr-20 xs-pd-20-10">
			<div class="min-height-200px">
				<div class="page-header">
					<div class="row">
						<div class="col-md-6 col-sm-12">
							<div class="title">
								<h4>Guest Lecture</h4>
							</div>
							<nav aria-label="breadcrumb" role="navigation">
								<ol class="breadcrumb">
									<li class="breadcrumb-item"><a href="dashboard.php">Dashboard</a></li>
									<li class="breadcrumb-item active" aria-current="page">Add Guest Lecture</li>
								</ol>
							</nav>
						</div>
						<div class="col-md-6 col-sm-12 text-right">
							<div class="dropdown">
								<a class="btn btn-primary" href="view_guest_lecture.php" role="button">
									View Guest Lecture
								</a>
							</div>
						</div>
					</div>
				</div>
				<!-- Default Basic Forms Start -->
				<div class="pd-20 bg-white border-radius-4 box-shadow mb-30">
					<form method="post">
			<?php 
                $sel=mysqli_query($connect,"select * from tbl_guest_lecture where fld_lecture_id='".$_GET['fld_lecture_id']."'") or die(mysqli_error($connect));
                $fetch=mysqli_fetch_array($sel);
            ?> 	
						<div class="form-group row">
							<label class="col-sm-12 col-md-2 col-form-label">Name of College<span class="text-danger">*</span> :</label>
							<div class="col-sm-12 col-md-10">
								<input class="form-control" type="text" placeholder="Name of College" required="" name="collge_name" oninput="this.value = this.value.replace(/[^a-zA-Z\s.]/g, '').replace(/(\..*)\./g, '$1');" value="<?php echo $fetch['fld_name_of_college']?>">
							</div>
						</div>
						<div class="form-group row">
							<label class="col-sm-12 col-md-2 col-form-label">Topic of Lecture<span class="text-danger">*</span> :</label>
							<div class="col-sm-12 col-md-10">
								<input class="form-control" type="text" placeholder="Topic of Lecture" required="" name="topic" oninput="this.value = this.value.replace(/[^a-zA-Z\s.]/g, '').replace(/(\..*)\./g, '$1');" value="<?php echo $fetch['fld_topic_of_lecture']?>">
							</div>
						</div>
						<div class="form-group row">
							<label class="col-sm-12 col-md-2 col-form-label">Lecture Date<span class="text-danger">*</span> :</label>
							<div class="col-sm-12 col-md-10">
								<input class="form-control date-picker" placeholder="Select Date" type="text" name="lecture_date" value="<?php echo $fetch['fld_lecture_date']?>">
							</div>
						</div>
						<div class="form-group row">
								<label class="col-sm-12 col-md-2 col-form-label">Lecture Time<span class="text-danger">*</span> : </label>
								<div class="col-sm-12 col-md-10">
									<input class="form-control time-picker" placeholder="Select time" type="text" name="lecture_time" required="" value="<?php echo $fetch['fld_lecture_time']?>">
								</div>
							</div>
						<div class="form-group row">
							<div class="col-sm-12 col-md-10">
							<center><input class="btn btn-success" value="Update" type="submit" name="update">&nbsp;
								<input class="btn btn-danger" value="Reset" type="reset">&nbsp;
								<a href="view_guest_lecture.php" class="btn btn-warning">Back</a></center>
							</div>
						</div>
					</form>
			</div>
			<?php include('include/footer.php'); ?>
		</div>
	</div>
	<?php include('include/script.php'); ?>
	
</body>

<?php 
	if (isset($_POST['update'])) 
	{

	extract($_POST);

	//  $abc=mysqli_query($connect,"select * from tbl_guest_lecture where fld_name_of_college='".$collge_name."' and fld_topic_of_lecture='".$topic."' and fld_lecture_date='".$new_lecture_date."' and fld_lecture_time='".$lecture_time."'");

 //    if(mysqli_num_rows($abc)==1)
 //     {
 //    	    echo "<script>";
 //            echo "alert('Guest Lecture Details Alrady Exist');";
 //            //echo "window.location.href='view_course_details.php';";
 //            echo "</script>";
 //     }
	// else
	// {
	$lecture_date=$_POST['lecture_date'];
	$new_lecture_date= date("Y-m-d",strtotime($lecture_date));

	$update=mysqli_query($connect,"update tbl_guest_lecture set
                fld_name_of_college='".$_POST['collge_name']."',
                fld_topic_of_lecture='".$_POST['topic']."',
                fld_lecture_date='".$new_lecture_date."',
                fld_lecture_time='".$_POST['lecture_time']."'
                where fld_lecture_id='".$_GET['fld_lecture_id']."'") or die(mysqli_error($connect));
	
	if ($update) 
	{
	    echo "<script>";
	    echo "alert('Guest Lecture Details Update Successfully');";
	    echo "window.location.href='view_guest_lecture.php';";
	    echo "</script>";                 
	}
	else
	{
	    echo "<script>";
	    echo "alert('Error');";
	    echo "</script>";
	}
	}
//}

?>
