<?php
function getExtn($filename){
$ext = explode(".",$filename);
return $ext[1];
}
$imgfile="";
include '../connection.php';
$slno = $_POST["slno"];
$fname = $_POST["fname"];
$desig = $_POST["desig"];
$email = $_POST["email"];
$mobile = $_POST["mobile"];
if (empty($fname)) {
// code...
echo "Enter Name";
exit();
}
if(is_array($_FILES)){
if(is_uploaded_file($_FILES['userImage']['tmp_name'])) {
$sourcePath = $_FILES['userImage']['tmp_name'];
$fileext = getExtn($_FILES['userImage']['name']);
$imgfile ="Blog".time().rand(10,100).".".$fileext;
if(move_uploaded_file($sourcePath,"../img/".$imgfile)){
@unlink("../img/".$img);
?>
<?php
}
}
}
if(empty($slno)){
$insert = "insert into coordinator(name,desig,mobile,email,img)values('$fname','$desig','$mobile','$email','$imgfile')";
$exc = $mysqli->query($insert);
echo "National Coordinator Add Succesfully";
file_put_contents("blogsss.txt", $insert);
}else{
if(empty($imgfile)){
$update = "update coordinator set name='$fname',desig='$desig',mobile='$mobile',email='$email' where id='$slno'";
$exc = $mysqli->query($update);
echo "National Coordinator Update Succesfully";
}else{
$update = "update coordinator set name='$fname',desig='$desig',mobile='$mobile',email='$email',img='$imgfile' where id='$slno'";
$exc = $mysqli->query($update);
echo "National Coordinator Update Succesfully";
}
}
?> |