JezK
Edit File: add_license.php
<?php //session_start(); include('session_check.php'); include('header.php'); // include('sa_operations.php'); $operation=new sa_operations(); $school_name=$operation->getschool_nameById($_GET['schid']); if(isset($_POST['addsubmit'])) { $sch_id = $_POST['sid']; $schname = $_POST['school_name']; $license_count= $_POST['noLicense']; $duration = $_POST['duration']; //$modules = $_POST['privilege']; $result=$operation->add_licensetoSchool($sch_id,$schname,$license_count,$duration); echo "<script>location.replace('license_management.php');</script>"; } ?> <body style="overflow-x: hidden;"> <div class="row" style="margin-top:30px;"> <div class="col-md-2 text-center" style="font:Arial, Helvetica, sans-serif;font-style:normal;font-size:14px; color:#000000; font-size:1.4em;"> <i class="fa-solid fa-plus " title ="Add License" style="font-size: 18px;"></i> Add License </div> </div> <form class="form-horizontal" method="post"> <div class="box-body " style="background-color:#fff; padding: 10px; font-family:Arial, Helvetica, sans-serif; font-size:13px; margin-top:40px;"> <div class="class " > <div class="form-group col-md-6 d-md-flex" style="margin-bottom:1.0%; clear:both;"> <div class="col-md-4 text-md-center "> <b style="color:#666666;">School Name</b><span style="color:#FF0000; margin:2px; "></span> </div> <div class="col-md-7"> <input type="text" class="form-control" id="school_name" name="school_name" style="height:29px;font-size:13px;" tabindex="1" value="<?php if(isset($_POST['school_name'])) echo $_POST['school_name'];else echo $school_name;?>" readonly> <!-- if there is an error--> <div class="col-md-10" id="errsch_school_name" style="color:#990000;margin-left:-15px;"></div> <!--end error--> </div> </div> </div> <div class="class" style="margin-top:10px;"> <div class="form-group col-md-6 d-md-flex" style="margin-bottom:1.0%; clear:both;"> <div class="col-md-4 text-md-center"> <b style="color:#666666;">No.Of Licenses</b><span style="color:#FF0000; margin:2px; ">*</span> </div> <div class="col-md-7"> <input type="hidden" name="sid" value="<?=$_GET['schid'];?>"> <input type="text" class="form-control" id="noLicense" maxlength="10" name="noLicense" style="height:29px;font-size:13px;" tabindex="2" value="<?php if(isset($_POST['noLicense'])) echo $_POST['noLicense'];?>"> <!-- if there is an error--> <div class="col-md-10" id="errsch_noLicense" style="color:#990000;margin-left:-15px;"></div> <!--end error--> </div> </div> </div> <div style="clear:both;"></div> <div class="class " style="margin-top:10px;"> <div class="form-group col-md-6 d-md-flex" style="margin-bottom:1.0%;"> <div class="col-md-4 text-md-center"> <b style="color:#666666; ">Duration</b><span style="color:#FF0000; margin:2px;">*</span> </div> <div class="col-md-7"> <select class="form-select" id="duration" name="duration" style="height:29px; font-size:12px;" tabindex="3"> <option value='0'>--Select Months--</option> <?php for($i=1;$i<=50;$i++) { if(isset($_POST['duration']) && $_POST['duration']==$i) echo "<option value='".$i."' selected>".$i."</option>"; else echo "<option value='".$i."'>".$i."</option>"; }?> </select> <!-- if there is an error--> <div class="col-md-10" id="errsch_duration" style="color:#990000;margin-left:-15px;"></div> <!--end error--> </div> </div> </div> <div class="form-group"> <div class="col-md-8" align="center"> <button type="submit" class="btn btn-default custom-button-width .navbar-right" name="addsubmit" style="margin:10px; " tabindex="21" onclick="return inputvalidations()">Add</button> <button type="button" class="btn btn-default custom-button-width .navbar-right" style="margin:10px;" tabindex="22" onclick="backtomain()">Cancel</button> </div> </div> </div> </form> <script> function inputvalidations() { $('#errsch_noLicense').text(''); $('#errsch_duration').text(''); var lic_count = document.getElementById('noLicense').value; var duration = document.getElementById('duration').value; var regex2=/^[0-9]*$/; if(lic_count=='') { $('#errsch_noLicense').text('Please enter No.Of Licenses'); $('#errsch_noLicense').show(); document.getElementById('noLicense').focus(); return false; } else if(!regex2.test(lic_count)) { $('#errsch_noLicense').text('Please enter valid No.Of Licenses'); $('#errsch_noLicense').show(); document.getElementById('noLicense').focus(); return false; } else if(duration=='0') { $('#errsch_duration').text('Please select License Duration'); $('#errsch_duration').show(); document.getElementById('duration').focus(); return false; } } function backtomain() { window.location.href="license_management.php"; } </script>