-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbanner_edit2.php
58 lines (48 loc) · 1.64 KB
/
banner_edit2.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
<?php
include"connect.php";
$id=$_GET['id'];
$sql="SELECT * from banner where id='$id'";
$result=mysqli_query($conn, $sql);
$row=mysqli_fetch_assoc($result);
if (isset($_POST['upload']))
{
$target = "banner/".basename($_FILES['image']['name']);
$image = $_FILES['image']['name'];
$description=$_POST['description'];
if($image==="")
{
$sql="UPDATE banner SET description='$description' where id=$id";
if ($conn->query($sql) === TRUE)
{
echo "New record updated successfully";
header('Location:banner.php');
}
else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
else
{
$filename="C:/xampp/htdocs/project/travel/banner/".$row['image'];
unlink($filename);
$sql="UPDATE banner SET image='$image', description='$description' where id=$id";
if ($conn->query($sql) === TRUE)
{
echo "New record updated successfully";
header('Location:banner.php');
}
else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
if (@move_uploaded_file($_FILES['image']['tmp_name'] , $target))
{
echo "updated successfully";
header('Location:banner.php');
}
else
{
echo "error ".$conn->error;
}
}
}
?>