Viewing file: edit_course.php (12.13 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
session_start();
include('includes/header.php');
$id = $_REQUEST['id'];
$result = $con->query("SELECT * FROM course_details WHERE id='" . $id . "'");
$row = mysqli_fetch_assoc($result);
if (isset($_POST['update'])) {
$technology = $_POST["technology"];
$title = $_POST["title"];
$hour = $_POST["hour"];
$placement = $_POST["placement"];
$cost = $_POST["cost"];
$description = $_POST["description"];
$course_details = $_POST["course_details"];
$heading_prefix = $_POST["heading_prefix"];
$heading = $_POST["heading"];
$url_code=$_POST['url_code'];
$main_content=$_POST['main_content'];
$resume_content=$_POST['resume_content'];
$priority=$_POST['priority'];
$course_type=$_POST['course_type'];
$query = "UPDATE course_details SET `heading_prefix` = '" . $heading_prefix . "',`heading` = '" . $heading . "',`priority` = '" . $priority . "',`technology` = '" . $technology . "',`name` = '" . $title . "', `hour` = '" . $hour . "',`placement` = '" . $placement . "',`cost`='" . $cost . "',`description`='" . $description . "',`course_details`='" . $course_details . "',`url_code`='".$url_code."',`main_content`='".$main_content."',`resume_content`='".$resume_content."',`course_type`='".$course_type."' WHERE id = $id";
$result = $con->query($query);
if ($_FILES["image"]["name"] != '') {
$targetDir = "../packageImages/";
$fileName = basename($_FILES["image"]["name"]);
$targetFilePath = $targetDir . $fileName;
$fileType = pathinfo($targetFilePath, PATHINFO_EXTENSION);
$image = $fileName;
$errors = array();
$file_name = $_FILES['image']['name'];
$file_size = $_FILES['image']['size'];
$file_tmp = $_FILES['image']['tmp_name'];
$file_type = $_FILES['image']['type'];
$file_ext = strtolower(end(explode('.', $_FILES['image']['name'])));
$extensions = array("jpeg", "jpg", "png");
if (in_array($file_ext, $extensions) === false) {
// $errors[]="extension not allowed, please choose a JPEG or PNG file.";
echo '<script>alert("extension not allowed, please choose a JPEG or PNG file.")</script>';
}
if ($file_size > 2097152) {
//$errors[]='File size must be excately 2 MB';
echo '<script>alert("File size must be excately 2 MB")</script>';
}
if (move_uploaded_file($_FILES["image"]["tmp_name"], $targetFilePath)) {
$query = "UPDATE course_details SET `image` = '" . $image . "' WHERE id = $id";
$result = $con->query($query);
}
}
echo "<script>window.location.href='view_courses.php';</script>";
exit;
}
?>
<div class="page-container">
<div class="left-content">
<div class="mother-grid-inner">
<!--header start here-->
<div class="header-main">
<div class="header-left">
<div class="logo-name"> <a href="admin_index.php">
<h3>SICS ADMIN</h3>
<br>
<h4>Edit Package</h4>
</a> </div>
<div class="clearfix"> </div>
</div>
<!--notification menu end -->
<div class="profile_details">
<ul>
<li class="dropdown profile_details_drop"> <a href="#" class="dropdown-toggle" data-toggle="dropdown" aria-expanded="false">
<div class="profile_img"> <span class="prfil-img"><img src="images/p1.png" alt=""> </span>
<div class="user-name">
<p>Srishti Innovative</p>
<span>Administrator</span> </div>
<i class="fa fa-angle-down lnr"></i> <i class="fa fa-angle-up lnr"></i>
<div class="clearfix"></div>
</div>
</a>
<ul class="dropdown-menu drp-mnu">
<li> <a href="admin_login.php"><i class="fa fa-sign-out"></i> Logout</a> </li>
</ul>
</li>
</ul>
</div>
<div class="span5">
<div class="row" style="margin-top:150px;margin-left:50px;">
<form method="post" action="" enctype="multipart/form-data">
<div class="txt-field">
<?php
$query1 = "select * from technologies order by name Asc";
$result1 = $con->query($query1);
?>
<label>Technology</label><br>
<select id="technology" name="technology" required style="width:25%;">
<option value="">------------Select------------</option>
<?php
while ($row1 = $result1->fetch_assoc()) {
$selected='';
if($row1["id"]==$row["technology"]){
$selected="selected";
}
?>
<option value="<?php echo $row1["id"]; ?>" <?php echo $selected; ?> ><?php echo $row1["name"]; ?></option>
<?php
}
?>
</select>
</div> <br>
<div class="txt-field">
<label>Show this package in website front end</label><br>
<select id="course_type" name="course_type" required style="width:25%;">
<option value="">------------Select------------</option>
<?php
if($row["course_type"]==0)
{
?>
<option value="0" selected>Show</option>
<option value="1">Hide</option>
<?php
}
if($row["course_type"]==1)
{
?>
<option value="0">Show</option>
<option value="1" selected>Hide</option>
<?php
}
?>
</select>
</div> <br>
<div class="txt-field">
<label>Priority</label><br>
<input type="text" id="priority" name="priority" placeholder="Priority" value="<?php echo $row['priority']; ?>">
</div>
<div class="txt-field">
<label>Page Heading</label><br>
<input type="text" id="heading_prefix" name="heading_prefix" placeholder="Prefix" value="<?php echo $row['heading_prefix']; ?>" > <input type="text" id="heading" name="heading" value="<?php echo $row['heading']; ?>" placeholder="Heading" >
</div> <br>
<div class="txt-field">
<input type="text" id="title" name="title" placeholder="Title" value="<?php echo $row['name']; ?>">
</div>
<br>
<div class="txt-field">
<input type="text" id="url_code" name="url_code" placeholder="Url Code" value="<?php echo $row['url_code']; ?>">
</div>
<br>
<div class="txt-field">
<input type="text" id="hour" name="hour" placeholder="Hour" value="<?php echo $row['hour']; ?>">
</div>
<br>
<div class="txt-field">
<input type="number" id="placement" name="placement" placeholder="Placement" value="<?php echo $row['placement']; ?>">
</div>
<br>
<div class="txt-field">
<input type="number" id="cost" name="cost" placeholder="Cost" value="<?php echo $row['cost']; ?>">
</div>
<br>
<div class="txt-field">
<input type="file" id="image" name="image" placeholder="image" ><?php if ($row['image']) {
echo '<img src="../packageImages/' . $row['image'] . '" style="width:100px;" />';
} ?>
</div>
<br>
<div class="txt-field">
<textarea placeholder="Description" rows="2" id="description" name="description"><?php echo $row['description']; ?></textarea>
</div>
<br>
<div class="txt-field">
<label>Course Details</label>
<textarea name="course_details" id="editor1" rows="10" cols="80"><?php echo $row['course_details']; ?></textarea>
</div>
<br>
<div class="txt-field">
<label>Main Content</label>
<textarea name="main_content" id="editor2" rows="10" cols="80"><?php echo $row['main_content']; ?></textarea>
</div>
<br>
<div class="txt-field">
<label>Resume Content</label>
<textarea name="resume_content" id="editor3" rows="10" cols="80"><?php echo $row['resume_content']; ?></textarea>
</div>
<br>
<input type="submit" name="update" class="logins" value="Submit">
</form>
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="clearfix"> </div>
</div>
<!--inner block start here-->
</div>
<div class="clearfix"> </div>
<!--slider menu-->
<?php include('includes/sidebar.php'); ?>
<div class="clearfix"> </div>
</div>
<!--slide bar menu end here-->
<?php include('includes/footer.php'); ?>
<script>
// Replace the <textarea id="editor1"> with a CKEditor 4
// instance, using default configuration.
CKEDITOR.replace('editor1');
</script>
<script>
// Replace the <textarea id="editor1"> with a CKEditor 4
// instance, using default configuration.
CKEDITOR.replace('editor2');
</script>
<script>
// Replace the <textarea id="editor1"> with a CKEditor 4
// instance, using default configuration.
CKEDITOR.replace('editor3');
</script>
|