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/add_sp_other_links.php
<?php include 'header.php'; 

$user_id =$_SESSION['user_id'];
?>
<main id="main-container">
    <div class="content content-narrow">
        <div class="row">
            <div class="col-lg-12">
                <h2 class="content-heading">Add SP Other Links</h2>
                    <?php
                        $curDate = date('Y-m-d H:i:s');
                        $message = "";
                        if(isset($_REQUEST['submit'])){

                            $errors = []; // Store all foreseen and unforseen errors here

                            $fileExtensions = ['jpg','jpeg','png']; // Get all the file extensions
                    
                            $fileName = $_FILES['myfile']['name'];
                            $fileSize = $_FILES['myfile']['size'];
                            $fileTmpName  = $_FILES['myfile']['tmp_name'];
                            $fileType = $_FILES['myfile']['type'];
                            $ext = pathinfo($fileName, PATHINFO_EXTENSION);
                            $fileExtension = strtolower(end(explode('.',$fileName)));
                    
                            $target_dir="/var/www/nclive/all_uploads/"; 
                            if(!in_array($ext,$fileExtensions)) {

                            $message= "<font style='color:red; float:left;'><h5>Please choose jpg, png, jpeg file <br>error on this file: ".$fileName." </h5></font>";
                            
                            } 

                            else {

                            if(!is_dir($target_dir)){
                              
                              mkdir($target_dir, 0777, true);
                              $target_file = $target_dir . $fileName;
                              $didUpload = move_uploaded_file($_FILES['myfile']["tmp_name"],$target_file);
                        
                            } else {
                        
                                $target_file = $target_dir . $fileName;
                                $didUpload = move_uploaded_file($_FILES['myfile']["tmp_name"],$target_file);
                            }
                        
                            if ($fileSize > 10000000) {
                                 $errors[] = "This file is more than 2MB. Sorry, it has to be less than or equal to 2MB";
                            }
                        }
                        $post_name=$_REQUEST['post_name'];
                        $post_slug=$_REQUEST['post_slug'];
                        $summary=$_REQUEST['summary'];
                        $description=$_REQUEST['description'];
                        $post_by=$_REQUEST['post_by'];
                        $status=$_REQUEST['status'];
                        $state=$_REQUEST['state'];
                        
                        $addotherlink="INSERT INTO sp_other_links SET post_name='$post_name', post_slug='$post_slug' , logo='$fileName', summary='$summary', description='$description', status='$status', post_by='$user_id', post_date='$curDate', state_slug='$state'";

                        $sql=$db->prepare($addotherlink);
                        $sql->execute();
                        $lastid = $db->lastInsertId();
                        if($lastid!=''){
                            $record_action="INSERT INTO sp_exam_update SET exam_id='$post_name', type='A', user_id='$user_id', date='$curDate', description='$description'";
                            
                              $sql2=$db->prepare($record_action);
                              $sql2->execute();

                              $message = '<h3 style="color:#000000;">Post Added 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>
                        <h2><?php echo $message ; ?></h2>
                    </div>
                <div class="block-content block-content-narrow">
                    <form class="js-validation-bootstrap form-horizontal" action="add_sp_other_links.php" method="post" name="myForm" id="form" enctype="multipart/form-data" >
                        <div class="form-group">
                            <label class="col-md-2 control-label" for="val-username">Post Name</label>
                            <div class="col-md-10">
                                <input class="form-control" type="text" name="post_name" placeholder="example:CGL Tier-I, SBI-Clerk">
                            </div>
                        </div>
            
                        <div class="form-group">
                            <label class="col-md-2 control-label" for="val-password">Post Slug</label>
                            <div class="col-md-10">
                                <input class="form-control" type="text" name="post_slug" placeholder="Enter Post slug">
                            </div>
                        </div>

                        <div class="form-group" >
                            <label class="col-md-2 control-label" for="val-select2">Select State</label>
                            <div class="col-md-10">
                                <select class="js-select2 form-control" id="type2" name="state">
                                    <?php 
                                    $sql = $db->prepare("SELECT state_slug,state_id,state_name FROM sp_states");
                                    $sql->execute();
                                    ?>
                                    <option selected="selected">--Select State--</option>
                                    <?php
                                    while($row=$sql->fetch(PDO::FETCH_ASSOC)) {
                                    ?>
                                    <option value="<?php echo $row['state_slug']; ?>"><?php echo $row['state_name']; ?></option>
                                   <?php
                                     } ?>
                                </select>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-2 control-label" for="val-password">Logo</label>
                            <div class="col-md-7">
                                <input class="form-control" type="file" name="myfile">
                            </div>
                            <div class="col-md-3">
                                <label class="error" >Only JPG , PNG, JPEG files:</label>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-2 control-label" for="val-confirm-password">Summary</label>
                            <div class="col-md-10">
                               <textarea class="ckeditor" name="summary" id="editor3"></textarea>
                            </div>
                        </div>

                        <div class="form-group">
                            <label class="col-md-2 control-label" for="val-confirm-password">Description</label>
                            <div class="col-md-10">
                               <textarea class="ckeditor" name="description" id="editor3"></textarea>
                            </div>
                        </div>


                        <div class="form-group">
                            <label class="col-md-2 control-label" for="val-confirm-password">Status</label>
                            <div class="col-md-10">
                              <select class="js-select2 form-control" name="status"  style="width: 100%;">
                                    <option value="1">Active</option> 
                                    <option value="0" selected="selected">Deactive</option> 
                                </select>
                            </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>
     <div class="content content-narrow">
            <div class="row">
                <div class="col-lg-12">
                    <h2 class="content-heading">Notification List</h2>
                        <div class="table-responsive">
                        <table id="other_links" class="table table-striped table-bordered dt-responsive nowrap" style="width:100%; cellspacing:0;">
                            <thead>
                                <tr class="danger">
                                    <th>Action</th>
                                    <th>Status</th>
                                    <th>Post Name</th>
                                    <th>Post Slug</th>
                                    <th>Logo</th>
                                    <th>Summary</th> 
                                    <th>Descripton</th>
                                    <th>Post By</th>
                                    <th>Last Update By</th>
                                    <th>Last Update Date</th>
                                </tr>
                            </thead>
                        </table> 
            
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script src="https://ajax.aspnetcdn.com/ajax/jquery.validate/1.9/jquery.validate.min.js"></script>

    <script type="text/javascript">
            jQuery.noConflict();
                jQuery(document).ready(function (){
                    jQuery('#other_links').dataTable({

                        "processing": true,
                        "serverSide": true,
                        "responsive": true,
                         
                        "ajax":  "data_sp_other_links.php",

                        "columns": [
                       
                            { "data": "id",
                                "render": function ( data, type, row ) {
                    
                                return '<a href="update_sp_other_links?id='+row.id+'">Edit</a>';
                                }
                            },
                            { "data": "status" },
                            { "data": "post_name" },
                            { "data": "post_slug"},   
                            { "data": "logo"},                   
                            { "data": "summary"},
                            { "data": "description"},
                            { "data": "post_by"},
                            { "data": "last_update_by"},
                            { "data": "last_update_date"}
                        ],
                        "bPaginate": true,
                        "responsive": true,
                        "iDisplayLength": 10,
                        "lengthMenu": [[10, 50, 100, 500, 1000], [10, 50, 100, 500, 1000]]
                            
        });                  
            });                                                    
                        </script> 
                    </div>
                </div>
            </div>
        </div>
</main>

<?php  include 'footer.php'; ?>