-
Notifications
You must be signed in to change notification settings - Fork 2
/
edit_volanteer_core.php
89 lines (79 loc) · 2.43 KB
/
edit_volanteer_core.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
require_once "lib/pdo_connection.php";
if(isset($_REQUEST['post_btn']))
{
try
{
$name = $_REQUEST['name'];
$position = $_REQUEST['position'];
$desc = $_REQUEST['description'];
$phn_num = $_REQUEST['phone_number'];
$image_file = $_FILES["file"]["name"];
$type = $_FILES["file"]["type"]; //file name "txt_file"
$size = $_FILES["file"]["size"];
$temp = $_FILES["file"]["tmp_name"];
$path="management_picture/".$image_file; //set upload folder path
$directory="management_picture/"; //set upload folder path for update time previous file remove and new file upload for next use
if(empty($name)){
$errorMsg="Please Enter Name";
}
else if(empty($position)){
$errorMsg="Please Enter Position";
}
else if(empty($desc)){
$errorMsg="Please Enter Description";
}
else if(empty($phn_num)){
$errorMsg="Please Enter Phone Number";
}
if($image_file)
{
if($type=="image/jpg" || $type=='image/jpeg') //check file extension
{
if(!file_exists($path)) //check file not exist in your upload folder path
{
if($size < 5000000) //check file size 5MB
{
unlink($directory.$data['pic']); //unlink function remove previous file
move_uploaded_file($temp, "management_picture/" .$image_file); //move upload file temperory directory to your upload folder
}
else
{
$errorMsg="Your File To large Please Upload 5MB Size"; //error message file size not large than 5MB
}
}
else
{
$errorMsg="File Already Exists...Check Upload Folder"; //error message file not exists your upload folder path
}
}
else
{
$errorMsg="Upload JPG, JPEG File Formate.....CHECK FILE EXTENSION"; //error message file extension
}
}
else
{
$image_file=$data['pic']; //if you not select new image than previous image sam it is it.
}
if(!isset($errorMsg))
{
$update_stmt=$db->prepare('UPDATE tbl_hr SET name=:name,position=:position,description=:description,phn_num=:phn_num,pic=:pic WHERE id=:id'); //sql update query
$update_stmt->bindParam(':name',$name);
$update_stmt->bindParam(':position',$position);
$update_stmt->bindParam(':description',$desc);
$update_stmt->bindParam(':phn_num',$phn_num);
$update_stmt->bindParam(':pic',$image_file); //bind all parameter
$update_stmt->bindParam(':id',$id);
if($update_stmt->execute())
{
header("location: volanteers.php");
}
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
}
?>