-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinputremedy.php
185 lines (121 loc) · 5.48 KB
/
inputremedy.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
<!DOCTYPE html>
<html>
<title>Create remedy</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="w3.css">
<link rel="stylesheet" href="../../cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<body>
<?php
include 'connection.php';
if(isset($_POST['submit'])){
// echo "olamzyweb is the best";
$remtitle = $_POST['remtit'];
$remcat = $_POST['remcat'];
// $remimg = $_POST['remimg'];
// $remposter = $_POST['remposter'];
@$author = $_POST['authq'];
$remtag = $_POST['remtag'];
$remedycontent = $_POST['remedy'];
$name = $_FILES['remposter']['name'];
$target_dir = "images/"; //this is the directory to upload to
//get_file name and set to target directory
$target_file = @($target_dir . basename($_FILES["remposter"]["name"]));
@($getfile_name = $_FILES['remposter']['name']);
@($getfile_size = $_FILES['remposter']['size']);
@($getfile_tmp_dir = $_FILES['remposter']['tmp_name']);
@($getfile_type = $_FILES['remposter']['type']);
@($identifyFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)));
if($getfile_size < "600000 bytes" ){
if($identifyFileType=="jpg" || $identifyFileType=="png"){
move_uploaded_file($_FILES["remposter"]["tmp_name"], $target_file);
echo "<script> alert('$getfile_name has been uploaded');</script>";
$name2 = $_FILES['remimg']['name'];
$target_dir2 = "images/"; //this is the directory to upload to
//get_file name and set to target directory
$target_file2 = @($target_dir . basename($_FILES["filetoupload"]["name"]));
@($getfile_name2 = $_FILES['remimg']['name']);
@($getfile_size2 = $_FILES['remimg']['size']);
@($getfile_tmp_dir2 = $_FILES['remimg']['tmp_name']);
@($getfile_type2 = $_FILES['remimg']['type']);
@($identifyFileType2 = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)));
if($getfile_size2 < "600000 bytes" ){
if($identifyFileType2=="jpg" || $identifyFileType2=="png"){
move_uploaded_file($_FILES["remimg"]["tmp_name"], $target_file);
echo "<script> alert('$getfile_name2 has been uploaded');</script>";
$query2 = "INSERT INTO remedies (title,content,auth,remcategory,remtag,remimg,remposter) VALUES('$remtitle','$remedycontent','$author','$remcat','$remtag','".$name."','".$name2."')";
$result2 = mysqli_query($conn, $query2);
if($result2 = true){
// echo '<script>alert("registration successful")</script>';
echo '<br><br><div class="alert success">
<span class="closebtn">×</span>
<strong>Product created successfully!</strong>
</div>';
// header('location:login.php');
// echo'<script>window.location.assign("login.php")</script>';
// echo $ema;
// echo $name;
}
}else {
echo "<script> alert('please upload an image with a jpg or png format '); </script>";
}
} else {
echo "<script> alert('$getfile_name2 is above 600kb. please upload an image less than 60 kb'); </script>";
}
}else {
echo "<script> alert('please upload an image with a jpg or png format '); </script>";
}
} else {
echo "<script> alert('$getfile_name is above 600kb. please upload an image less than 60 kb'); </script>";
}
}
?>
<form action="inputremedy.php" method="POST" enctype="multipart/form-data" class="w3-container w3-card-4 w3-light-grey w3-text-blue w3-margin">
<h2 class="w3-center">Create remedy</h2>
<div class="w3-row w3-section">
<div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-user"></i></div>
<div class="w3-rest">
<input class="w3-input w3-border" name="remtit" type="text" placeholder="Remedy title">
</div>
</div>
<div class="w3-row w3-section">
<div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-user"></i></div>
<div class="w3-rest">
<input class="w3-input w3-border" name="remcat" type="text" placeholder="Remedy category">
</div>
</div>
<div class="w3-row w3-section">
<div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-envelope-o"></i></div>
<div class="w3-rest">
<input class="w3-input w3-border" name="authq" type="text" placeholder="Author">
</div>
</div>
<div class="w3-row w3-section">
<div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-phone"></i></div>
<div class="w3-rest">
<input class="w3-input w3-border" name="remedy" type="text" placeholder="remedy here">
</div>
</div>
<div class="w3-row w3-section">
<div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-phone"></i></div>
<div class="w3-rest">
<input class="w3-input w3-border" name="remtag" type="text" placeholder="remedy disease/tags">
</div>
</div>
<div class="w3-row w3-section">
<div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-pencil"></i></div>
Remedy poster
<div class="w3-rest">
<input class="w3-input w3-border" name="remposter" type="file" placeholder="remedy poster">
</div>
</div>
<div class="w3-row w3-section">
<div class="w3-col" style="width:50px"><i class="w3-xxlarge fa fa-pencil"></i></div>
Remedy img
<div class="w3-rest">
<input class="w3-input w3-border" name="remimg" type="file" placeholder="remedy poster">
</div>
</div>
<input type="submit" class="w3-button w3-block w3-section w3-blue w3-ripple w3-padding" name="submit">Send
</form>
</body>
</html>