<?php include ("connection/conn.php");

$selectfranchise="select * from registrations where id='".$_REQUEST['id']."'";
$queryfranchise=mysqli_query($link,$selectfranchise);
$assoc=mysqli_fetch_assoc($queryfranchise);

	if(isset($_POST['submit']))
		{
		$name=addslashes($_POST['name']);
		$father_name=addslashes($_POST['father_name']);
		$mother_name=addslashes($_POST['mother_name']);
		$mobile=$_POST['mobile'];
		$email=$_POST['email'];
		$city=$_POST['city'];
		$address=addslashes($_POST['address']);
		$reg_no=$_POST['reg_no'];
		$course_name=$_POST['course_name'];
		$dob=$_POST['dob'];
		
		  
			if($name=="")
			{
				$Error_msg="Please enter name.<br>";
			}
			 if($_FILES['img']['name']!="")
			{
                $img=$_FILES['img']['name'];
                $tenthorgext=substr(strrchr($img,"."),1);
                $img=date('d-m-Yhis').rand(0,9999).'.'.$tenthorgext;
                $upload_path_img=$_FILES['img']['tmp_name'];	
               move_uploaded_file($upload_path_img,"../listblg/".$img);
            }
			else if($_FILES['img']['name']=="")
			{
				$img=$assoc['img'];
			}
			if($Error_msg=="")
			{	
			 $updateFranchise="update registrations set name='".$name."',father_name='".$father_name."',mother_name='".$mother_name."',mobileno='".$mobile."',email='".$email."',reg_no='".$reg_no."',city='".$city."',address='".$address."',course='".$course_name."',dob='".$dob."',img='".$img."' where id='".$_REQUEST['id']."' ";
			mysqli_query($link,$updateFranchise);
			header("location:manage-registration.php?success=Registration has been Update sucessfully.");
			exit();
			}
		}
?>
<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<title>Administrator</title>
		<link href="css/bootstrap.css" rel="stylesheet" />
		<link href="css/style.css" rel="stylesheet" />
		<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
		<script language="javascript" src="Editor/scripts/innovaeditor.js" type="text/javascript"></script>
		<link rel="icon" href="/images/favicon.ico" type="image/x-icon">
	</head>
	
	<body>
		<div id="wrapper">
			<?php
				include("top-header.php");
				include("right-sec.php");
			?>
			<div id="page-wrapper" >
				<div id="page-inner">
					<div class="row">
						<div class="col-md-12">
							<h3 class="page-header">
								Update Registration<small></small>
							</h3>
							<div class="table-sec">
								<div class="srch_box">
									<form name="pnews" id="pnews" method="post" action="" enctype="multipart/form-data">
										<div class="row">
											
											<div class="col-md-12 col-xs-12">
												<div class="pnl_box"> 
													<div class="col-md-6 col-xs-6">	
														<div class="form-group form-select">
															<label>Registration No <span>*</span></label>
															<input class="form-control" type="text"  name="reg_no" value="<?php echo $assoc['reg_no'];?>">
														</div>		
													</div>
													<div class="col-md-6 col-xs-6">	
														<div class="form-group form-select">
															<label>Name <span>*</span></label>
															<input class="form-control" type="text"  name="name" value="<?php echo $assoc['student_first_name'];?>">
														</div>		
													</div>
													
													
													<div class="col-md-6 col-xs-6">
														<div class="form-group form-select">
															<label>Father Name <span>*</span></label>
															<input class="form-control" type="text"  name="father_name" value="<?php echo $assoc['father_name'];?>">
														</div>		
													</div>
														<div class="col-md-6 col-xs-6">
														<div class="form-group form-select">
															<label>Mother Name <span>*</span></label>
															<input class="form-control" type="text"  name="mother_name" value="<?php echo $assoc['mother_name'];?>">
														</div>		
													</div>
													<div class="col-md-6 col-xs-6">
														<div class="form-group form-select">
															<label>Mobile <span>*</span></label>
															<input class="form-control" type="text"  name="mobile" value="<?php echo $assoc['mobileno'];?>">
														</div>		
													</div>
													<div class="col-md-6 col-xs-6">
														<div class="form-group form-select">
															<label>Email ID <span>*</span></label>
															<input class="form-control" type="text"  name="email" value="<?php echo $assoc['email'];?>"> 
														</div>		
													</div>
													<div class="col-md-6 col-xs-6">
														<div class="form-group form-select">
															<label>Address <span>*</span></label>
															<input class="form-control" type="text"  name="address" value="<?php echo $assoc['address'];?>">
														</div>		
													</div>
													<div class="col-md-6 col-xs-6">
														<div class="form-group form-select">
															<label>City <span>*</span></label>
															<input class="form-control" type="text"  name="city" value="<?php echo $assoc['city'];?>">
														</div>		
													</div>
													<div class="col-md-6 col-xs-6">
														<div class="form-group form-select">
															<label>State <span>*</span></label>
															<input class="form-control" type="text"  name="state" value="<?php echo $assoc['state'];?>">
														</div>		
													</div>
														<div class="col-md-6 col-xs-6">
														<div class="form-group form-select">
															<label>Course Name <span>*</span></label>
															<input class="form-control" type="text"  name="course_name" value="<?php echo $assoc['course'];?>">
														</div>		
													</div>
														<div class="col-md-6 col-xs-6">
														<div class="form-group form-select">
															<label>DOB<span>*</span></label>
															<input class="form-control" type="text"  name="dob" value="<?php echo $assoc['dob'];?>">
														</div>		
													</div>
													<div class="col-md-6 col-xs-6">
														<div class="form-group form-select">
															<label>Remarks <span>*</span></label>
															<textarea name="news_description"  rows="5" cols="10" id="txtContent" ><?php echo $assoc['news_description'];?></textarea><?php //include("Editor/editor.php");?>
														</div>		
													</div>
													
													
													<div class="col-md-6 col-xs-6">	
														<div class="form-group form-select">
															<label>Photo <span>*</span></label>
															<input class="form-control" type="file"  name="img"><img src="/listblg/<?php echo $assoc['photo'];?>" height="50" width="50"  />
														</div>		
													</div>
													
												</div>	
												
											</div>
										</div>
										<div class="row">
											<div class="col-md-4 col-xs-4">	
												<div class="btn_sec">
												   
										<input type="submit" name="submit" value="Submit" />
												</div>
											</div>
										</div>
									</form>
								</div>
							</div>
						</div>
					</div> 
				</div>
			</div>
			<footer class="footer-sec">
				<div class="container">
					<div class="row">
						<div class="col-md-12">
							<p class="text-center">All right reserved.<a href="">sgecouncil.org</a></p>
						</div>
					</div>
				</div>
			</footer>
		</div>
		
		
		<!-- jQuery Js -->
		<script src="js/jquery-1.10.2.js"></script>
		<script src="js/bootstrap.min.js"></script>
		<script src="js/jquery.metisMenu.js"></script>
		<script src="js/custom-scripts.js"></script>
	</body>
</html>
