HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-31-18-78 6.17.0-1017-aws #17~24.04.1-Ubuntu SMP Tue May 26 21:09:53 UTC 2026 aarch64
User: ubuntu (1000)
PHP: 8.2.31
Disabled: NONE
Upload Files
File: /var/www/nclive/technc/exam_links.php
<?php include 'header.php'; ?>
<style>
  #form .form-group label.error {
    color: #FB3A3A;
    display: inline-block;
    margin: 0px 0 0px 0px;
    padding: 0;
    text-align: left;
  }
</style>
<link href="assets/js/plugins/select2/select2.min.css" rel="stylesheet">

<main id="main-container">
  <div class="content content-narrow">
    <div class="row">
      <div class="col-lg-12">
        <h2 class="content-heading">Add Exam Links</h2>
        <?php
        $curDate = date('Y-m-d H:i:s');
        if (isset($_REQUEST['submit'])) {
          $examname = $_REQUEST['examname'];
          $entity = $_REQUEST['entity'];
          $display = $_REQUEST['dis_text'];
          $dis_text_dates = $_REQUEST['dis_text_dates'];
          $desc = $_REQUEST['editor'];
          $link = $_REQUEST['link'];
          $type = $_REQUEST['search_type'];
          if ($type == 'N') {
            $date = $_REQUEST['normal'];
          } else if ($type == 'FT') {
            $date = $_REQUEST['fromdate'] . ',' . $_REQUEST['todate'];
          } else if ($type == 'T') {
            $date = $_REQUEST['text'];
          }

          $query = "INSERT INTO sp_exam_links SET exam_id='$examname',entity_id='$entity',display_text='$display',display_text_dates='$dis_text_dates',description='$desc',links='$link',date_type='$type',date='$date',status='0',add_by='$user_id',add_date='$curDate',update_date='$curDate'";
          $sql = $db->prepare($query);
          $sql->execute();
          echo '<h3 style="color:#000000;">Data submit successfully</h3>';
        }
        ?>
        <div class="block">
          <div class="block-header">
            <ul class="block-options">
              <li>
                <button type="button"><i class="si si-settings"></i></button>
              </li>
            </ul>
            <h3 class="block-title"></h3>
          </div>
          <div class="block-content block-content-narrow">
            <form class="js-validation-bootstrap form-horizontal" action="exam_links.php" method="post" id="form">
              <div class="form-group">
                <label class="col-md-2 control-label" for="val-select2">Select Exam</label>
                <div class="col-md-10">
                  <select class="js-select2 exam-dropdown form-control" name="examname" style="width: 100%;">
                    <?php
                    $sql = $db->prepare("SELECT exam_id,exam_name FROM sp_exam order by exam_id desc");
                    $sql->execute();
                    ?>
                    <option selected="selected">--Select exam--</option>
                    <?php while ($row = $sql->fetch(PDO::FETCH_ASSOC)) { ?>
                      <option value="<?php echo $row['exam_id']; ?>"><?php echo $row['exam_name']; ?></option>
                    <?php } ?>
                  </select>
                </div>
              </div>
              <div class="form-group">
                <label class="col-md-2 control-label" for="val-select2">Select Exam Entity</label>
                <div class="col-md-10">
                  <select class="js-select2 form-control" name="entity" style="width: 100%;">
                    <?php
                    $sql = $db->prepare("SELECT id, name FROM sp_exam_entity order by display_order");
                    $sql->execute();
                    ?>
                    <option selected="selected">--Select Entity--</option>
                    <?php while ($row = $sql->fetch(PDO::FETCH_ASSOC)) { ?>
                      <option value="<?php echo $row['id']; ?>"><?php echo $row['name']; ?></option>
                    <?php } ?>
                  </select>
                </div>
              </div>
              <div class="form-group">
                <label class="col-md-2 control-label" for="val-username">Display Text (Links)<span class="text-danger">*</span></label>
                <div class="col-md-10">
                  <input class="form-control" type="text" name="dis_text" placeholder="Display text for LINKS ONLY">
                </div>
              </div>
              <div class="form-group">
                <label class="col-md-2 control-label" for="val-username">Display Text (Dates)<span class="text-danger">*</span></label>
                <div class="col-md-10">
                  <input class="form-control" type="text" name="dis_text_dates" placeholder="Display text for DATES ONLY">
                </div>
              </div>
              <div class="form-group">
                <label class="col-md-2 control-label" for="val-email">Description<span class="text-danger">*</span></label>
                <div class="col-md-10">
                  <textarea class="ckeditor" name="editor"></textarea>
                </div>
              </div>
              <div class="form-group">
                <label class="col-md-2 control-label" for="val-password">Links<span class="text-danger">*</span></label>
                <div class="col-md-10">
                  <input class="form-control" type="text" name="link" placeholder="">
                </div>
              </div>
              <div class="form-group">
                <label class="col-md-2 control-label" for="val-password">On Date<span class="text-danger">*</span></label>
                <div class="col-md-1">
                  <input type="radio" name="search_type" class="radio" value="N" />
                </div>
                <div class="col-md-5" id="normal" style="display:none;">
                  <input type="text" placeholder="Select Dates" class="dates_opted dates_opted_1 width_100" name="normal" style="width:400px">
                </div>
              </div>
              <div class="form-group">
                <label class="col-md-2 control-label" for="val-password">From & To Date<span class="text-danger">*</span></label>
                <div class="col-md-1">
                  <input type="radio" name="search_type" value="FT" class="radio" />
                </div>
                <div class="col-md-5" id="fromto" style="display:none;">
                  <input class="form-control" type="date" name="fromdate" placeholder="">
                  <input class="form-control" type="date" name="todate" placeholder="">
                </div>
              </div>
              <div class="form-group">
                <label class="col-md-2 control-label" for="val-password">Text<span class="text-danger">*</span></label>
                <div class="col-md-1">
                  <input type="radio" name="search_type" class="radio" value="T" />
                </div>
                <div class="col-md-5" id="text" style="display:none;">
                  <input type="text" placeholder="Text" class="width_100" name="text" style="width:400px">
                </div>
              </div>
              <div class="form-group">
                <div class="col-md-10 col-md-offset-2">
                  <button class="btn btn-lg btn-primary" type="submit" name="submit">Submit</button>
                </div>
              </div>
            </form>
          </div>
        </div>
      </div>
    </div>
  </div>
</main>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>

<script type="text/javascript" charset="utf-8">
  $(document).ready(function() {
    $('.radio').on('change', function() {

      if (this.value == 'N') {
        $("#normal").css('display', 'block');
        $("#fromto").css('display', 'none');
      } else if (this.value == 'FT') {
        $("#fromto").css('display', 'block');
        $("#normal").css('display', 'none');
      } else if (this.value == 'T') {
        $("#fromto").css('display', 'none');
        $("#normal").css('display', 'none');
        $("#text").css('display', 'block');
      }
    });
  });
</script>

<script type="text/javascript">
  (function($, W, D) {
    var JQUERY4U = {};
    JQUERY4U.UTIL = {
      setupFormValidation: function() {
        //form validation rules
        $("#form").validate({
          rules: {
            examname: {
              required: true,
            },
            entity: {
              required: true,
            },
            editor: {
              required: true,
            }
          },
          messages: {
            examname: "Please select exam name",
            entity: "Please select exam name",
            editor: "Please fill exam title details",
            link: "Please fill link details"
          },
          submitHandler: function(form) {
            form.submit();
          }
        });
      }
    }
    //when the dom has loaded setup form validation rules
    $(D).ready(function($) {
      JQUERY4U.UTIL.setupFormValidation();
    });
  })(jQuery, window, document);
</script>

<script>
  function cleanArray(actual) {
    var newArray = new Array();
    for (var i = 0; i < actual.length; i++) {
      if (actual[i]) {
        newArray.push(actual[i]);
      }
    }
    return newArray;
  }
  jQuery(document).ready(function($) {
    $('.dates_opted').each(function(index) {
      var dates = [];
      $(this).datepicker({
        dateFormat: "yy-mm-dd",
        onSelect: function() {
          dates = cleanArray(dates);
          dates.push($(this).val());
          //console.log(dates);
          $(this).val(dates);
        },
        showAnim: 'clip',
        changeYear: true,
        changeMonth: true,
        yearRange: "2000:2030"

      }).keyup(function(e) {
        if (e.keyCode == 8 || e.keyCode == 46) {
          var datesString = $(this).val().split(",");
          dates = [];
          for (var i = 0; i < datesString.length - 1; i++) {
            dates.push(datesString[i]);
          }
          $(this).blur();
          $(this).val(dates);
        }
      });
    });
  });
</script>
<?php include 'footer.php'; ?>
<script src="assets/js/plugins/select2/select2.min.js"></script>
<script>
        $(document).ready(function() {
            $('.exam-dropdown').select2();
        });
</script>