GIF89a
<?php ob_start(); ini_set('error_reporting', E_STRICT); include("connect.php"); mysqli_set_charset($conn,'utf8'); date_default_timezone_set('Asia/Kolkata'); $ename=$_POST['ename']; $sdate=$_POST['sdate']; $edate=$_POST['edate']; $target_dir='events_img/'.mt_rand(100,987).mt_rand(985,1453).trim($_FILES["pic"]["name"]); $FileType = strtolower(pathinfo($target_dir,PATHINFO_EXTENSION)); if($FileType != "png" && $FileType != "jpg" && $FileType != "jpeg" ) { echo '<script>alert("Invalid event image format");</script>'; echo '<script>window.location.href="events.php";</script>'; } else { // check event is already exist or not $sql="SELECT * FROM `events` WHERE `event_sdate`='".$sdate."'"; $rs=mysqli_query($conn,$sql); $check=mysqli_num_rows($rs); if($check>0) { echo '<script>alert("Another event present on this start date. \n Suggestion : Change start date & end Date");</script>'; echo '<script>window.location.href="events.php";</script>'; } else { move_uploaded_file($_FILES["pic"]["tmp_name"],$target_dir); // save event $sql2="INSERT INTO `events`(`event_name`, `event_image`, `event_sdate`, `event_edate`) VALUES ('".$ename."','".$target_dir."','".$sdate."','".$edate."')"; $rs2=mysqli_query($conn,$sql2); if($rs2>0) { echo '<script>alert("Yahoo !! Event schduled on the given date successfully");</script>'; echo '<script>window.location.href="events.php";</script>'; } else { echo '<script>alert("Error : Unable to save event | Contact to developers");</script>'; echo '<script>window.location.href="events.php";</script>'; } } } ?>