<?php
session_start();
if($_SESSION['user']!=true)
{
header('Location:login.php');
}
$error="";
?>
<?php
include("include/databaseq.php");
$title=$_POST['title'];
$date=$_POST['date'];
$description=$_POST['description'];
function GetImageExtension($imagetype)
{
if(empty($imagetype)) return false;
switch($imagetype)
{
case 'image/bmp': return '.bmp';
case 'image/gif': return '.gif';
case 'image/jpeg': return '.jpg';
case 'image/png': return '.png';
default: return false;
}
}
if (!empty($_FILES["uploadedimage"]["name"])) {
$file_name=$_FILES["uploadedimage"]["name"];
$temp_name=$_FILES["uploadedimage"]["tmp_name"];
$imgtype=$_FILES["uploadedimage"]["type"];
$ext= GetImageExtension($imgtype);
$imagename=date("d-m-Y")."-".time().$ext;
$target_path = "/images/news/".$imagename;
if(move_uploaded_file($temp_name, $target_path)) {
$query_upload="INSERT into recent_news (title,date,description,images_path,submission_date) VALUES
('$title','$date','$description','".$target_path."','".date("Y-m-d")."')";
mysql_query($query_upload) or die("error in $query_upload == ----> ".mysql_error());
?>
<script>
alert("News Updated");
window.location="recent_news.php";
</script>
<?php
}
else{
exit("Error While uploading image on the server");
}
}
?>
t12425 0 Newbie Poster
t12425 0 Newbie Poster
mattster 195 Practically a Master Poster Featured Poster
veedeoo 474 Junior Poster Featured Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.