[
MAINHACK
]
Mail Test
BC
Config Scan
HOME
Create...
New File
New Folder
Viewing / Editing File: edit_question.php
<?php include 'header.php'; ?> <?php $count=1; $sr='upload_questions';//$subcategory=''; $stmt =$show->readwithdata($sr,'qid',$_REQUEST['qid']); $num = $stmt->rowCount(); if($num>0){ $count=1; while ($row = $stmt->fetch(PDO::FETCH_ASSOC)){ extract($row); $uid[]=$row['id']; $category=$row['category']; $question=$row['question']; $subcategory[]=$row['sub_category']; $option1=$row['option1']; $option2=$row['option2']; $option3=$row['option3']; $option4=$row['option4']; $answer=$row['answer']; $img=$row['main_image']; $img1=$row['image1']; $img2=$row['image2']; $img3=$row['image3']; $img4=$row['image4']; $answer_img=$row['answer_img']; } } ?> <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">Edit Question</div> </div> <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'; $stmt=$show->readAll($table1); $num=$stmt->rowCount(); if($num>0){ while($row=$stmt->fetch(PDO::FETCH_ASSOC)){ echo "<option value='".$row['category']."'";if($category==$row['category']) echo "selected"; echo ">".$row['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-12"> <label>Question</label> <textarea name="question"> <?php echo $question; ?></textarea></div> <div class="clearfix"></div> </div> <?php if($img!=""){?> <div class="form-group"> <div class="col-md-12"> <label>Main image</label> <input type="file" name="main_image" onchange="return fileValidation('main_image','1200')" id="main_image"/> <img src="<?=$pic_img?>/<?=$img?>" width="150"> <div class="clearfix"></div> </div> </div> <?php } ?> <div class="form-group"> <div class="col-md-6"> <label>Options 1</label> <input type="text" class="form-control" name="option1" value="<?php echo $option1; ?>" /> </div> <?php if($img1!=""){?> <div class="col-md-6"> <label>Options 1 image</label> <input type="file" name="image1" onchange="return fileValidation('image1','1200')" id="image1"/> <img src="<?=$pic_img?>/<?=$img1?>" width="150"> <div class="clearfix"></div> </div> <?php } ?> <div class="clearfix"></div> </div> <div class="form-group"> <div class="col-md-6"> <label>Options 2</label> <input type="text" class="form-control" name="option2" value="<?php echo $option2; ?>" /> </div> <?php if($img2!=""){?> <div class="col-md-6"> <label>>Options 2 image</label> <input type="file" name="image2" onchange="return fileValidation('image2','1200')" id="image2"/> <img src="<?=$pic_img?>/<?=$img2?>" width="150"> <div class="clearfix"></div> </div> <?php } ?> <div class="clearfix"></div> </div> <div class="form-group"> <div class="col-md-6"> <label>Options 3</label> <input type="text" class="form-control" name="option3" value="<?php echo $option3; ?>" /> </div> <?php if($img3!=""){?> <div class="col-md-6"> <label>Main image</label> <input type="file" name="image3" onchange="return fileValidation('image3','1200')" id="image3"/> <img src="<?=$pic_img?>/<?=$img3?>" width="150"> <div class="clearfix"></div> </div> <?php } ?> </div> <div class="form-group"> <div class="col-md-6"> <label>Options 4</label> <input type="text" class="form-control" name="option4" value="<?php echo $option4; ?>" /> </div> <?php if($img4!=""){?> <div class="col-md-6"> <label>Main image</label> <input type="file" name="image4" onchange="return fileValidation('image4','1200')" id="image4"/> <img src="<?=$pic_img?>/<?=$img4?>" width="150"> <div class="clearfix"></div> </div> <?php } ?> <div class="clearfix"></div> </div> <div class="form-group"> <div class="col-md-6"> <label>Answer:</label> <input class="form-control" type="text" id="" name="answer" value="<?php echo $answer; ?>" /> </div> <?php if($answer_img!=""){?> <div class="col-md-6"> <label>Main image</label> <input type="file" name="answer_img" onchange="return fileValidation('answer_img','1200')" id="answer_img"/> <img src="<?=$pic_img?>/<?=$answer_img?>" width="150"> <div class="clearfix"></div> </div> <?php } ?> <div class="clearfix"></div> </div> <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> </div> </div> </form> </div> <?php if(isset($_POST['sub'])){ $allowed = ["question","option1","option2","option3","option4","answer","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['main_image']['tmp_name']) || is_uploaded_file($_FILES['main_image']['tmp_name'])) { $setStr .= "`main_image` = :main_image,"; $img=$show->imageEdit($_FILES['main_image']['name']); move_uploaded_file($_FILES['main_image']['tmp_name'],"../product_img/".$img); $params['main_image'] =$img; } if(file_exists($_FILES['descriptive_img']['tmp_name']) || is_uploaded_file($_FILES['descriptive_img']['tmp_name'])) { $setStr .= "`descriptive_img` = :descriptive_img,"; $descriptive_img=$show->imageEdit($_FILES['descriptive_img']['name']); move_uploaded_file($_FILES['descriptive_img']['tmp_name'],"../product_img/".$descriptive_img); $params['descriptive_img'] =$descriptive_img; } if(file_exists($_FILES['image1']['tmp_name']) || is_uploaded_file($_FILES['image1']['tmp_name'])) { $setStr .= "`image1` = :image1,"; $option1_img=$show->imageEdit($_FILES['image1']['name']); move_uploaded_file($_FILES['image1']['tmp_name'],"../product_img/".$option1_img); $params['image1'] =$option1_img; } if(file_exists($_FILES['image2']['tmp_name']) || is_uploaded_file($_FILES['image2']['tmp_name'])) { $setStr .= "`image2` = :image2,"; $option2_img=$show->imageEdit($_FILES['image2']['name']); move_uploaded_file($_FILES['image2']['tmp_name'],"../product_img/".$option2_img); $params['image2'] =$option2_img; } if(file_exists($_FILES['image3']['tmp_name']) || is_uploaded_file($_FILES['image3']['tmp_name'])) { $setStr .= "`image3` = :image3,"; $option3_img=$show->imageEdit($_FILES['image3']['name']); move_uploaded_file($_FILES['image3']['tmp_name'],"../product_img/".$option3_img); $params['image3'] =$option3_img; } if(file_exists($_FILES['image4']['tmp_name']) || is_uploaded_file($_FILES['image4']['tmp_name'])) { $setStr .= "`image4` = :image4,"; $option4_img=$show->imageEdit($_FILES['image4']['name']); move_uploaded_file($_FILES['image4']['tmp_name'],"../product_img/".$img); $params['image4'] =$option4_img; } if(file_exists($_FILES['answer_img']['tmp_name']) || is_uploaded_file($_FILES['answer_img']['tmp_name'])) { $setStr .= "`answer_img` = :answer_img,"; $answer_img=$show->imageEdit($_FILES['answer_img']['name']); move_uploaded_file($_FILES['answer_img']['tmp_name'],"../product_img/".$answer_img); $params['answer_img'] =$answer_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['qid'] =$_REQUEST['qid']; $show->table ='upload_questions'; $show->cols =$setStr; $show->id_name ='qid'; $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> </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.22 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