Viewing file: add_popupimage.php (5.86 KB) -rw-rw-r-- Select action/file-type: (+) | (+) | (+) | Code (+) | Session (+) | (+) | SDB (+) | (+) | (+) | (+) | (+) | (+) |
<?php
session_start();
include('includes/header.php');
if (isset($_POST['submit'])) {
$title = $_POST["title"];
$description = $_POST["description"];
$targetDir = "/var/www/html/popup_image/";
$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'])));
//
// if ($file_size > 2097152) {
// //$errors[]='File size must be excately 2 MB';
// echo '<script>alert("File size must be excately 2 MB")</script>';
// }
if (empty($errors) == true) {
if (move_uploaded_file($_FILES["image"]["tmp_name"], $targetFilePath)) {
$query = "insert into popup_image(title,image,description)values('" . $title . "','" . $image . "','" . $description . "')";
$result = $con->query($query);
$count = $con->affected_rows;
if ($count > 0) {
echo "<script>window.location.href='view_popupimage.php';</script>";
} else {
echo "<script>window.location.href='add_popupimage.php';</script>";
}
} else {
echo '<script>alert("File Upload not successfull")</script>';
}
} else {
echo '<script>alert("Something went wrong!")</script>';
}
}
?>
<?php
// Storing session data
$_SESSION["role"];
if(!isset($_SESSION["role"]))
{
header("location:admin_login.php");
?>
<script type="text/javascript">
window.location.href = "admin_login.php";
</script>
<?php
}
else
{
?>
<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><?php echo $_SESSION["name"];?></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="logout.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 Popup Image</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" required>
</div>
<br>
<div class="txt-field">
<label>Popup Image</label><br>
<input type="file" id="image" name="image" placeholder="Student Image" required>
</div>
<br>
<div class="txt-field">
<label>Description</label><br>
<textarea placeholder="Description" id="description" name="description" rows="5" cols="40"></textarea>
</div>
<br>
<input type="submit" class="logins" name="submit" 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>
<?php
}
?>
|