forked from bmcbride/leaflet-users-map
-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert_user.php
36 lines (34 loc) · 1.3 KB
/
insert_user.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
<?php
$name = htmlspecialchars(trim($_POST['name']));
$email = htmlspecialchars(trim($_POST['email']));
$website = htmlspecialchars(trim($_POST['website']));
$city = htmlspecialchars(trim($_POST['city']));
$lat = htmlspecialchars(trim($_POST['lat']));
$lng = htmlspecialchars(trim($_POST['lng']));
$token = mt_rand(100000, 999999);
$db = new PDO('sqlite:leaflet.sqlite');
$db->exec("INSERT INTO users (name, email, website, city, lat, lng, token) VALUES ('$name', '$email', '$website', '$city', '$lat', '$lng', '$token');");
$db = NULL;
$subject = "Welcome to the Leaflet Users Map!";
$body = '
<html>
<head>
</head>
<body>
<p>Thanks for adding yourself to the map!</p>
Your account information:<br>
-------------------------<br>
Email: '.$email.'<br>
Token: '.$token.'<br>
-------------------------<br><br>
Should you need to edit your information, please visit the map and click on the Remove me button.<br>
Enter your email and unique token to remove your entry from the database.<br>
Feel free to add yourself back to the map at any time!
</body>
</html>
';
$headers = 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
$headers .= 'From: Leaflet Users Map <[email protected]>' . "\r\n";
mail($email, $subject, $body, $headers, "[email protected]");
?>