ok
Direktori : /home/ngwcolle/public_html/LIBRARY-NGWC/admin/ |
Current File : //home/ngwcolle/public_html/LIBRARY-NGWC/admin/edit-student.php |
<?php session_start(); //DB conncetion include_once('includes/config.php'); error_reporting(0); //validating Session if (strlen($_SESSION['aid']==0)) { header('location:logout.php'); } else{ //Code for record deletion if($_GET['requestid']){ $tid=$_GET['requestid']; $cquery=mysqli_query($con,"select * from tbl_students where id ='$tid'"); $singleRow = mysqli_fetch_row($cquery); } if(isset($_POST['submit'])) { // $admyear=$_POST['admyear']; // $acayear=$_POST['acayear']; $mobno=$_POST['mobilenumber']; // $dept=$_POST['dept']; // $lcno=$_POST['lcno']; $stname=$_POST['stname']; // $pieces=explode("|",$dept); // $rn=$_POST['rn']; $mobile=$_POST['mobile']; $dob=$_POST['dob']; $email=$_POST['email']; $gender=$_POST['gender']; $patrontype=$_POST['ptype']; $duplicate=mysqli_query($con,"select * from tbl_students where rollno='$rn' and status='0'"); if (mysqli_num_rows($duplicate)>0) { echo '<script>alert("Student Roll number not exist in the Library.")</script>'; } else{ $query=mysqli_query($con, "update tbl_students set stname='$stname',dob='$dob',mobile='$mobile',gender='$gender',email='$email',patrontype='$patrontype' where id='$tid'"); if ($query) { // $dt = date('Y-m-d'); echo '<script>alert("Patron Updated.")</script>'; echo "<script>window.location.href ='all-students.php'</script>"; }else{ echo '<script>alert("Something Went Wrong. Please try again.")</script>'; } } } ?> <!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="description" content=""> <meta name="author" content=""> <title>Edit Student</title> <link rel="icon" type="image/x-icon" href="../assets/favicon.ico" /> <!-- Custom fonts for this template --> <link href="vendor/fontawesome-free/css/all.min.css" rel="stylesheet" type="text/css"> <link href="https://fonts.googleapis.com/css?family=Nunito:200,200i,300,300i,400,400i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet"> <!-- Custom styles for this template --> <link href="css/sb-admin-2.min.css" rel="stylesheet"> <!-- Custom styles for this page --> <link href="vendor/datatables/dataTables.bootstrap4.min.css" rel="stylesheet"> </head> <body id="page-top"> <!-- Page Wrapper --> <div id="wrapper"> <!-- Sidebar --> <?php include_once('includes/sidebar.php');?> <!-- End of Sidebar --> <!-- Content Wrapper --> <div id="content-wrapper" class="d-flex flex-column"> <!-- Main Content --> <div id="content"> <!-- Topbar --> <?php include_once('includes/topbar.php');?> <!-- End of Topbar --> <!-- Begin Page Content --> <div class="container-fluid"> <!-- Page Heading --> <div class="d-sm-flex align-items-center justify-content-between mb-4"> <h1 class="h3 mb-0 text-gray-800">Edit Student from Library</h1> </div> <!-- DataTales Example --> <div class="card shadow mb-4"> <div class="card-header py-3"> <h6 class="m-0 py-2 font-weight-bold text-primary">Edit Student</h6> <a href="all-students.php" class="float-right mt-0 btn btn-success"> <i class="fa fa-arrow-left" aria-hidden="true"></i> Back</a> </div> <div class="card-body"> <div class="container py-5"> <div class="row"> <div class="col-md-10 mx-auto"> <form method="post" action=""> <div class="form-group row"> <div class="col-sm-6"> <label for="inputFirstname">Select Admission Year</label> <select name="admyear" id="admyear" class="form-control" required disabled>--select -- <option value="">--Select Admission Year--</option> <?php $starting_year =date('Y', strtotime('-3 year')); $ending_year = date('Y'); for($starting_year; $starting_year <= $ending_year; $starting_year++) { if($singleRow[5]==$starting_year) { echo '<option value="'.$starting_year.'" selected=selected >'.$starting_year.'</option>'; } // if($starting_year == date('Y')){ // echo '<option value="'.$starting_year.'" selected=selected>'.$starting_year.'</option>'; // } // else{ // echo '<option value="'.$starting_year.'">'.$starting_year.'</option>'; // } } ?> </select> <!-- <input type="text" class="form-control" id="inputFirstname" placeholder="First name"> --> </div> <div class="col-sm-6"> <label for="inputLastname">Academic Year</label> <input type="text" class="form-control" id="acayear" value="<?php echo $singleRow[4];?>" readonly name="acayear"placeholder="Academic Year" required> </div> </div> <div class="form-group row"> <div class="col-sm-6"> <label for="inputAddressLine1">Select Department/Section</label> <select name="dept" id="dept" class="form-control" required disabled> <option value="">--Select Department--</option> <?php $sqli = "SELECT * FROM tbl_department"; $result = mysqli_query($con, $sqli); while ($row = mysqli_fetch_array($result)) { if($singleRow[3]==$row['id']){ echo '<option value="'.$row['shortcode']."|".$row['id'].'" selected>'.$row['name'].'</option>'; } } ?> </select> <!-- <input type="text" class="form-control" id="inputAddressLine1" placeholder="Street Address"> --> </div> <div class="col-sm-6"> <label for="inputAddressLine2">Library Card no.</label> <input required type="text" disabled class="form-control" id="lcno" name="lcno" value="<?php echo $singleRow[10];?>" placeholder="Line 2"> </div> </div> <div class="form-group row"> <div class="col-sm-6"> <label for="inputCity">Name</label> <input required type="text" class="form-control" id="inputCity" placeholder="Name of the Student" value="<?php echo $singleRow[2];?>" name="stname"> </div> <div class="col-sm-3"> <label for="inputState">Roll No/Employee ID</label> <input required type="text" class="form-control" id="rn" value="<?php echo $singleRow[1];?>" name="rn" placeholder="XX22-0000"> </div> <div class="col-sm-3"> <label for="inputState">Patron Type.</label> <select name="ptype" id="ptype" class="form-control" required> <option value="">--Select Patron Type--</option> <option value="1" <?php if($singleRow[12]=='1') echo 'selected="selected"'; ?>>Staff</option> <option value="2" <?php if($singleRow[12]=='2') echo 'selected="selected"'; ?>>Student</option> <option value="3" <?php if($singleRow[12]=='3') echo 'selected="selected"'; ?>>Alumni</option> <option value="4" <?php if($singleRow[12]=='4') echo 'selected="selected"'; ?>>Most Valuable Partner</option> </select> </div> </div> <div class="form-group row"> <div class="col-sm-6"> <label for="inputCity">Mobile No</label> <input type="number" value="<?php echo $singleRow[7];?>" required class="form-control" pattern="[6789][0-9]{9}" title="Please enter valid phone number" name="mobile" placeholder="Mobile no." required> </div> <div class="col-sm-6"> <label for="inputState">Date of Birth</label> <input type="date" name="dob" value="<?php echo $singleRow[6];?>" required class="form-control" id="inputState" placeholder="State"> </div> </div> <div class="form-group row"> <div class="col-sm-6"> <label for="inputContactNumber">Email-ID</label> <input type="email" name="email" value="<?php echo $singleRow[9];?>" class="form-control" id="inputContactNumber" placeholder="Contact Number"> </div> <div class="col-sm-6"> <label for="inputWebsite">Gender</label> <select name="gender" id="gender" required class="form-control" > <option value="" selected>Select Gender</option> <option value="Male" <?php if($singleRow[8]=='Male') echo 'selected="selected"'; ?>>Male</option> <option value="Female" <?php if($singleRow[8]=='Female') echo 'selected="selected"'; ?>>Female</option> <option value="Transgender" <?php if($singleRow[8]=='Transgender') echo 'selected="selected"'; ?>>Transgender</option> </select> <!-- <input type="text" class="form-control" id="inputWebsite" placeholder="Website"> --> </div> </div> <button type="submit" class="btn btn-primary px-4 float-right" name="submit">Save</button> </form> </div> </div> </div> </div> </div> </div> <!-- /.container-fluid --> </div> <!-- End of Main Content --> <!-- Footer --> <?php include_once('includes/footer.php');?> <!-- End of Footer --> </div> <!-- End of Content Wrapper --> </div> <!-- End of Page Wrapper --> <!-- Scroll to Top Button--> <?php include_once('includes/footer2.php');?> <!-- Bootstrap core JavaScript--> <script src="vendor/jquery/jquery.min.js"></script> <script src="vendor/bootstrap/js/bootstrap.bundle.min.js"></script> <!-- Core plugin JavaScript--> <script src="vendor/jquery-easing/jquery.easing.min.js"></script> <!-- Custom scripts for all pages--> <script src="js/sb-admin-2.min.js"></script> <!-- Page level plugins --> <script src="vendor/datatables/jquery.dataTables.min.js"></script> <script src="vendor/datatables/dataTables.bootstrap4.min.js"></script> <!-- Page level custom scripts --> <script src="js/demo/datatables-demo.js"></script> </body> </html> <script> $(document).ready(function(){ $("#admyear").change(function(){ var selectedCountry = $(this).children("option:selected").val(); var finalyear=parseInt(selectedCountry)+3; $('#acayear').val(selectedCountry+"-"+finalyear); $('#dept').val(""); }); $("#dept").change(function(){ var slecteddept = $(this).children("option:selected").val(); alert(slecteddept); }); // get libcard no $("#dept").change(function(){ var secid1 = $(this).val(); var nameArr = secid1.split('|'); if($('#admyear').val()=="") { alert("Select Admission Year"); $(this).val(""); return false; } else { var clid1 = $('#admyear').val(); } $.ajax({ type:"POST", url: "ajax/getlibcardno.php", data: {secid:nameArr[0],admyear:clid1}, dataType:'json', success:function(data){ alert(data.libcardno); $('#lcno').val(data.libcardno); } }); // $("#nod").val(days); // $('#minage').val(clid); }); //libcard ends }); </script> <?php } ?>