-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdetails5_add.php
80 lines (75 loc) · 2.8 KB
/
details5_add.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
<?php
session_start();
if(!isset($_SESSION['FullName'])){
header('location:login_admin.php');
}
include 'connect.php';
$icon = "";
$selectquery = "SELECT * FROM `navbar4`";
$query = mysqli_query($con, $selectquery);
if($query){
$fav_icon = mysqli_fetch_assoc($query);
$icon = $fav_icon['Image'];
}
if(isset($_POST['submit'])){
$name = $_POST['name'];
$location_img = $_FILES['location_img']['name'];
$location_tmp_name = $_FILES['location_img']['tmp_name'];
$location_folder = "details_img/$location_img";
$checkquery = "SELECT * FROM `details5` WHERE `Image`='$location_img'";
$result = mysqli_query($con, $checkquery);
$num_rows = mysqli_num_rows($result);
if($num_rows > 0){ ?>
<script>
alert('Details already exists...');
</script>
<?php }
else{
$insertquery = "INSERT INTO `details5` (`Image`, `Name`, `Date`) VALUES ('$location_img', '$name', current_timestamp())";
$result = mysqli_query($con, $insertquery);
if($result){
move_uploaded_file($location_tmp_name, $location_folder); ?>
<script>
alert('Details has added successfully!');
location.replace('details_details5.php');
</script>
<?php }
else{ ?>
<script>
alert('Something went wrong...');
</script>
<?php }
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Add Details</title>
<link rel="icon" type="image/png" href="images/<?php echo $icon; ?>" />
<link rel="stylesheet" href="footer_menu_add.css">
</head>
<body>
<section id="container">
<form action="<?php echo htmlentities($_SERVER['PHP_SELF']); ?>" method="post" enctype="multipart/form-data">
<h2>Add Details</h2>
<div class="input">
<label for="location_img">Image</label>
<input type="file" id="location_img" accept="image/*" name="location_img" autofocus autocomplete="off" required>
</div>
<div class="input">
<label for="name">Name</label>
<input type="text" id="name" name="name" autofocus autocomplete="off" required>
</div>
<div class="input" id="field-submit">
<button type="submit" name="submit" id="btn">Add Details</button>
</div>
<div class="input">
<button type="submit" id="btn1"><a href="details_details5.php">Go Back</a></button>
</div>
</form>
</section>
</body>
</html>