Viewing file: edit_placedstudents.php (9.41 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 placed_students WHERE id='" . $id . "'");
$row = mysqli_fetch_assoc($result);
if (isset($_POST['update'])) {
$home_view1=$_POST["home_view"];
if($home_view1=='on')
{
$home_view=1;
}
else
{
$home_view=0;
}
$title = $_POST["title"];
$name = $_POST["name"];
$technology = $_POST["technology"];
$company = $_POST["company"];
$testimonial = $_POST["testimonial"];
$description = $_POST["description"];
if ($_FILES["image"]["name"] != '') {
$targetDir = "../placedstudents/";
$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>';
exit;
}
// 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 placed_students SET `title` = '" . $title . "',`name` = '" . $name . "',`technology` = '" . $technology . "',`company` = '" . $company . "', `testimonial` = '" . $testimonial . "', `image` = '" . $image . "',`description` = '" . $description . "',`home_view` = '" . $home_view . "' WHERE id = $id";
$result = $con->query($query);
}
}else{
$query = "UPDATE placed_students SET `title` = '" . $title . "',`name` = '" . $name . "',`technology` = '" . $technology . "',`company` = '" . $company . "', `testimonial` = '" . $testimonial . "',`description` = '" . $description . "',`home_view` = '" . $home_view . "' WHERE id = $id";
$result = $con->query($query);
}
echo "<script>window.location.href='view_placedstudents.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>
<!--<img id="logo" src="" alt="Logo"/>-->
</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="#"><i class="fa fa-cog"></i> Settings</a> </li>
<li> <a href="#"><i class="fa fa-user"></i> Profile</a> </li> -->
<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:95px;margin-left:50px;">
<h4 style="text-align: left;margin: 0% 0% 3%;color: #337cc5;">Add Placed Students</h4>
<form method="post" action="" enctype="multipart/form-data">
<div class="txt-field">
<label>Title</label><br>
<input type="text" id="title" name="title" placeholder="Title" value="<?php echo $row['title']; ?>" required>
</div>
<br>
<div class="txt-field">
<label>Student Name</label><br>
<input type="text" id="name" name="name" placeholder="Student Name" value="<?php echo $row['name']; ?>" required>
</div>
<br>
<div class="txt-field">
<?php
$query1 = "select * from technologies order by id desc";
$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>Placed Company</label><br>
<input type="text" id="company" name="company" value="<?php echo $row['company']; ?>" placeholder="Placed Company name" required>
</div>
<br>
<div class="txt-field">
<label>Testimonial</label><br>
<textarea name="testimonial" id="testimonial" rows="5" cols="40"><?php echo $row['testimonial']; ?></textarea>
</div>
<br>
<div class="txt-field">
<label>Student Image</label><br>
<input type="file" id="image" name="image" placeholder="Student Image" >
<?php if ($row['image']) {
echo '<img src="../placedstudents/' . $row['image'] . '" style="width:100px;" />';
} ?>
</div>
<br>
<div class="txt-field">
<label>View in Home page</label>
<input type="checkbox" id="home_view" name="home_view" <?php if($row['home_view']==1) { ?> checked="checked" <?php } ?> >
</div>
<br>
<div class="txt-field">
<label>Description</label><br>
<textarea placeholder="Description" id="description" name="description" rows="5" cols="40"><?php echo $row['description']; ?></textarea>
</div>
<br>
<input type="submit" class="logins" name="update" value="Submit">
</form>
</div>
</div>
<div class="clearfix"> </div>
</div>
<div class="clearfix"> </div>
</div>
<!--heder end here-->
<!-- script-for sticky-nav -->
<!-- /script-for sticky-nav -->
<!--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>
</script>
|