-
Notifications
You must be signed in to change notification settings - Fork 0
/
add-offer.php
223 lines (168 loc) · 6.26 KB
/
add-offer.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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
<?php
require_once 'config.php';
// error_reporting(0);
if ($_SERVER['REQUEST_METHOD'] == "POST"){
$title = trim($_POST['title']);
$product_type = ($_POST['product_type']);
$details = trim($_POST['details']);
$start = trim($_POST['start']);
$due = trim($_POST['due']);
$items = implode(',', $product_type);
$filename = $_FILES["offer-logo"]["name"];
$tempname = $_FILES["offer-logo"]["tmp_name"];
$folder = "img/". $filename;
$sql = "INSERT INTO offers(title, image, product_type, details, start,due) VALUES( '$title', '$filename','$items', '$details' , '$start', '$due' )";
$result = mysqli_query($conn, $sql);
if ($result)
{
// header("location: A-offer.php");
// $_SESSION[''] = $answer;
// $_SESSION['mail'] = $email_id;
require "login-system-main/Mail/phpmailer/PHPMailerAutoload.php";
$mail = new PHPMailer;
$mail->isSMTP();
$mail->Host='smtp.gmail.com';
$mail->Port=587;
$mail->SMTPAuth=true;
$mail->SMTPSecure='tls';
$mail->Username='[email protected]';
$mail->Password='Gendustem';
$sql = "SELECT * FROM target_customers ";
$res = mysqli_query($conn, $sql);
if (mysqli_num_rows($res) > 0) {
while ($row = mysqli_fetch_assoc($res)) {
$mail->setFrom('[email protected]','MyCRM' );
$mail->addAddress($row['email']);
}
$mail->isHTML(true);
$mail->Subject= $title;
$mail->Body= " <p>Your Today's Offer is here...</p> <br>
<h2>" . $title . " </h2> <br>
<h4>" . $details . "</h4>
<br><br>
<b>Your CRM</b>
";
if(!$mail->send()){
?>
<script>
alert("<?php echo " Failed, Invalid Email "?>");
</script>
<?php
}else{
?>
<script>
alert("<?php echo "offer sent to target customers. " ?>");
window.location.href = "A-offer.php";
</script>
<?php
}}
}
// }
else{
echo"something went wrong". mysqli_error();
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>ADD OFFER</title>
<link href="css/add-offer.css" type="text/css" rel="stylesheet">
</head>
<body>
<style>
body {
background-color: rgb(218, 217, 238);
}
</style>
<header>
<nav class="navbar">
<ul>
<li><a href="logout.php"> <button class="logbtn">Log out</button></a></li>
<!-- <li><a href="login page.php"> <button class="logbtn">Log in</button></a></li> -->
<li><a href="offer_report.php" >Reports</a></li>
<li><a href="Admin FAQs.php" >FAQs</a></li>
<li><a href="product_data.php" >Product Data</a></li>
<li><a href="employee_data.php">Employee Data</a></li>
<li><a href="A-offer.php" class="active">Offers</a></li>
<li><a href="admin page.php" >Home </a></li>
<img src="img/crm-icon-png.png" alt="logo">
</ul>
</nav>
</header>
<h1>Add New Offer</h1>
<form id="form" method="post" enctype="multipart/form-data">
<hr>
<!-- Create Form -->
<!-- Details -->
<div class="form-control">
<label for="title" id="label-name">
Title
</label>
<!-- Input Type Text -->
<input type="text"
id="name" name="title"
placeholder="Enter Title of offer" />
</div>
<div class="form-control">
<label for="" id="label-name">
Offer logo
</label>
<!-- Input Type Text -->
<input type="file" id="myfile" onchange="#displaypic" name="offer-logo">
</div>
<div class="form-control">
<label for="product" id="label-email">
Product Category
</label>
<!-- Input Type Email-->
<input type="checkbox" id ="Fashion "name="product_type[]" value="Fashion">
<label for="Fashion"> Fashion</label><br>
<input type="checkbox" id="Mobiles and Tablets" name="product_type[]" value="Mobiles and Tablets">
<label for="Mobiles and Tablets"> Mobiles and Tablets</label><br>
<input type="checkbox" id="Consumer Electronics" name="product_type[]" value="Consumer Electronics">
<label for="Consumer Electronics">Consumer Electronics</label><br>
<input type="checkbox" id="Books" name="product_type[]" value="Books">
<label for="Books">Books</label><br>
<input type="checkbox" id="Baby Products" name="product_type[]" value="Baby Products">
<label for="Baby Products"> Baby Products</label><br>
<input type="checkbox" id="Groceries" name="product_type[]" value="Groceries">
<label for="Groceries"> Groceries</label><br>
<div class="form-control">
<label for="details" id="label-email">
Details
</label>
<!-- Input Type Email-->
<input type="text"
id="details" name="details"
placeholder="Enter details of the offer" />
</div>
<div class="form-control">
<label for="start" id="label-age">
Start date
</label>
<!-- Input Type Text -->
<input type="date"
id="start" name="start"
placeholder="Enter start date" />
</div>
<div class="form-control">
<label for="end" id="label-age">
Due date
</label>
<!-- Input Type Text -->
<input type="date"
id="end" name="due"
placeholder="Enter due date" />
</div>
<!-- Multi-line Text Input Control -->
<button type="submit" name="submit">
Add
</button>
</form>
</body>
</html>
</form>