-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemaildata.php
More file actions
26 lines (26 loc) · 1.24 KB
/
emaildata.php
File metadata and controls
26 lines (26 loc) · 1.24 KB
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
<?php
$email = $_POST['email'];
$price = $_POST['price'];
$id = intval($_POST['hiddenVal']);
$servername = "localhost";
$username = "pricemerger";
$password = "Pricemerge123!";
$database = "Popularpricemerge";
$time = time();
try {
$conn = new PDO("mysql:host=$servername;dbname=$database", $username, $password);
// set the PDO error mode to exception
$conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sql = "SELECT * FROM `Notifications` WHERE `id`=$id AND `email`='$email';";
$result = $conn -> query($sql);
if($result -> rowCount() == 0){
$toExec = "INSERT INTO `Notifications` (`email`, `priceVal`, `id`, `time`, `emailed`) VALUES ('$email', '$price', '$id', '$time', 'false');";
$conn -> exec($toExec);
echo '<div class = "container"><center><h1 style = "color: black">Thanks for using PriceMerge! We will contact you once the price drops!</h1></center></div>';
} else {
echo "<div class = 'container'><center><h1 style = 'color: black'>We are already tracking this product for the email $email</h1></center></div>";
}
} catch(PDOException $e) {
echo "Failed: ". $e->getMessage();
}
?>