-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlocations_edit2.php
64 lines (49 loc) · 1.85 KB
/
locations_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
59
60
61
62
63
64
<?php
include"connect.php";
$id=$_GET['l_id'];
if (isset($_POST['submit']))
{
$target = "locations/".basename($_FILES['image']['name']);
$image = $_FILES['image']['name'];
$l_description=$_POST['l_description'];
$l_name=$_POST['l_name'];
if($image==="")
{
$sql="UPDATE locations SET l_description='$l_description',l_name='$l_name' where l_id=$id";
if ($conn->query($sql) === TRUE)
{
echo "Record updated successfully (no image)";
header('Location:locations2.php');
}
else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
}
else
{
$sql="SELECT * from locations where l_id='$id'";
$result=mysqli_query($conn, $sql);
$row=mysqli_fetch_assoc($result);
$filename="C:/xampp/htdocs/project/travel/locations/".$row['l_image'];
unlink($filename);
$sql1="UPDATE locations SET l_image='$image', l_description='$l_description',l_name='$l_name' where l_id=$id";
if ($conn->query($sql1) === TRUE)
{
echo "Record updated successfully (image)";
header('Location:locations2.php');
}
else {
echo "Error: " . $sql1 . "<br>" . $conn->error;
}
if (@move_uploaded_file($_FILES['image']['tmp_name'] , $target))
{
echo "uploaded successfully";
header('Location:locations2.php');
}
else
{
echo "error ".$conn->error;
}
}
}
?>