-
Notifications
You must be signed in to change notification settings - Fork 0
/
update_slider.php
48 lines (45 loc) · 1.19 KB
/
update_slider.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
<?php
$id=$_GET['id'];
$sql=mysqli_query($con,"select * from slider where id='$id' ");
$res=mysqli_fetch_assoc($sql);
$img=$res['image'];
$path="../image/Slider/$img";
if(isset($update))
{
$imgNew=$_FILES['img']['name'];
if($imgNew=="")
{
$sql="update slider set caption='$cap' where id='$id' ";
}
else
{
$sql="update slider set caption='$cap',image='$imgNew' where id='$id' ";
//delete old image
unlink($path);
move_uploaded_file($_FILES['img']['tmp_name'],"../image/Slider/".$_FILES['img']['name']);
}
if(mysqli_query($con,$sql))
{
header('location:dashboard.php?option=slider');
}
}
?>
<form method="post" enctype="multipart/form-data">
<table class="table table-bordered">
<tr style="height:40">
<th>Caption</th>
<td><input type="text" name="cap" value="<?php echo $res['caption']; ?>" class="form-control"/></td>
</tr>
<tr>
<th>Image</th>
<td><input type="file" name="img" accept="image/*" class="form-control"/>
<img src="<?php echo $path; ?>" height="100px" width="100px"/>
</td>
</tr>
<tr>
<td colspan="2">
<input type="submit" class="btn btn-primary" value="Update" name="update"/>
</td>
</tr>
</table>
</form>