-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsert_image.php
74 lines (45 loc) · 1.66 KB
/
insert_image.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
<!DOCTYPE HTML>
<?php
$db = mysqli_connect("localhost" , "root" ,"" , "db_images") ;
?>
</html>
<head>
<title>Inserting Image </title>
</head>
<body>
<p align="right"><a href = 'logout.php'>LOGOUT</a></p>
<form method = "post" action = "insert_image.php" enctype = "multipart/form-data">
<table width = "100" height = "100" align = "center" border = "2" bgcolor = "#19BFD1">
<tr align = "center">
<td colspan = "2"<h1>Insert new Image:</h1></td>
</tr>
<tr>
<td align = "right" <b>Image </b> </td>
<td> <input type = "file" name = "img" /> </td>
</tr>
<tr>
<td align = "right" <b>Description</b> </td>
<td> <input type = "text" name = "img_desc" /> </td>
</tr>
<tr>
<td> <input type = "hidden" name = "albm_id" value = <?php if(isset($_GET['insert'])){ echo $_GET['insert'] ; } ?> /> </td>
</tr>
<tr align = "center" >
<td colspan = "2"> <input type = "submit" name = "insert_image" value = "insert image"/></td>
</tr>
<?php
if(isset($_POST['insert_image'])){
global $alb_id ;
$image_name = $_FILES['img']['name'] ;
$temp_name = $_FILES['img']['tmp_name'] ;
$img_desc = $_POST['img_desc'] ;
// $alb_name = $_POST['alb_name'] ;
$al_id = $_POST['albm_id'] ;
move_uploaded_file($temp_name , "images/$image_name") ;
$query = "insert into image_info(image , Date , description , album_id) values('$image_name' , NOW() , '$img_desc' , '$al_id')" ;
$run_query = mysqli_query($db , $query) ;
header("Refresh: 2;URL=album_photos.php?id=$al_id") ;
}
?>
</body>
</html>