<?php
function getExtn($filename){
$ext = explode(".",$filename);
return $ext[1];
}
$imgfile="";
include '../connection.php';
$slno = $_POST["slno"];
$cname = $_POST["cname"];
$desig = $_POST["desig"];
$remark = $_POST["remark"];
$dob = $_POST["dob"];
$doa = $_POST["doa"];
$email = $_POST["email"];
$mobile = $_POST["mobile"];
$facebook = $_POST["facebook"];
$twitter = $_POST["twitter"];
$linkedin = $_POST["linkedin"];
$state = $_POST["state"];
$active = $_POST["active"];
$for = $_POST["for"];
if(empty($cname)){
echo "Name Empty";
exit();
}
if(is_array($_FILES)){
if(is_uploaded_file($_FILES['userImage']['tmp_name'])) {
$sourcePath = $_FILES['userImage']['tmp_name'];
$fileext = getExtn($_FILES['userImage']['name']);
$imgfile ="img".time().rand(10,100).".".$fileext;
if(move_uploaded_file($sourcePath,"../img/".$imgfile)){
@unlink("../img/".$img);
?>
<?php
}
}
}
if(empty($slno)){
$insert = "insert into leadership(name,desig,remark,img,dob,doa,email,mobile,facebook,twitter,linkedin,fors,active,state)values('$cname','$desig','$remark','$imgfile','$dob','$doa','$email','$mobile','$facebook','$twitter','$linkedin','$for','$active','$state')";
$exc = $mysqli->query($insert);
echo "Leadership Add Succesfully";
}else{
if(empty($imgfile)){
$update = "update leadership set name='$cname',desig='$desig',remark='$remark',dob='$dob',doa='$doa',email='$email',mobile='$mobile',facebook='$facebook',twitter='$twitter',linkedin='$linkedin',fors='$for',active='$active',state='$state' where id='$slno'";
$exc = $mysqli->query($update);
echo "Leadership Update Succesfully";
}else{
$update = "update leadership set img='$imgfile, name='$cname',desig='$desig',remark='$remark',dob='$dob',doa='$doa',email='$email',mobile='$mobile',facebook='$facebook',twitter='$twitter',linkedin='$linkedin',fors='$for',active='$active',state='$state' where id='$slno'";
$exc = $mysqli->query($update);
echo "Leadership Update Succesfully";
}
}
?> |