-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaddgallary.php
86 lines (69 loc) · 2.02 KB
/
addgallary.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
<html>
<head>
<title>Add Data</title>
</style>
</head>
<body>
<?php
//including the database connection file
include_once("config.php");
require('top.inc.php');
if(isset($_POST['Submit'])) {
$head = mysqli_real_escape_string($conn, $_POST["head"]);
move_uploaded_file($_FILES["photo"]["tmp_name"],"gallaryimages/" . $_FILES["photo"]["name"]);
$photo=$_FILES["photo"]["name"];
// checking empty fields
if(empty($head) || empty($photo)) {
if(empty($head)) {
echo "<font color='red'>Name field is empty.</font><br/>";
}
if(empty($photo)) {
echo "<font color='red'>Photo field is empty.</font><br/>";
}
//link to the previous page
echo "<br/><a href='javascript:self.history.back();'>Go Back</a>";
} else {
// if all the fields are filled (not empty)
//insert data to database
$result = mysqli_query($conn, "INSERT INTO gallary(gallaryimage,gallaryhead) VALUES('$photo','$head')");
//display success message
echo "<font color='green'>Data added successfully.";
echo "<br/><a href='gallary.php'>View Result</a>";
}
}
?>
<div class="content pb-0">
<div class="animated fadeIn">
<div class="row">
<div class="col-lg-12">
<div class="card">
<div class="card-header"><strong>ADD IMAGES</strong> </div>
<form action="addgallary.php" method="post" name="form1" enctype="multipart/form-data">
<table width="25%" border="0">
<div class="card-body card-block">
<div class="form-group">
<tr>
<td>HEADING</td>
<td><input type="text" name="head"></td>
</tr>
<tr>
<td>Photo</td>
<td><input type="file" name="photo" ></td>
</tr>
<tr>
<td></td>
<td><input type="submit" name="Submit" value="Add"></td>
</tr>
</div> </div>
</table>
</form>
<div class='field_error'>
<a href="gallary.php">view gallery</a></div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>