-
Notifications
You must be signed in to change notification settings - Fork 0
/
connect.php
28 lines (22 loc) · 927 Bytes
/
connect.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
<?php
$host = getenv("WEDDING_HOST");
$user = getenv("WEDDING_USER");
$pass = getenv("WEDDING_PASS");
$db = getenv("WEDDING_DB");
$con = pg_connect("host=$host dbname=$db user=$user password=$pass")
or die ("Could not conect: " . pg_last_error());
$name = pg_escape_string($_POST['name']);
$attending = pg_escape_string($_POST['attending']);
$email = pg_escape_string($_POST['email']);
$song_request = pg_escape_string($_POST['song']);
$other_guests = pg_escape_string($_POST['otherGuests']);
$query = "insert into rsvp2 (name, attending, email, song_request, other_guests) values ('$name', '$attending', '$email', '$song_request', '$other_guests')";
$result = pg_query($query);
if ($result) {
$response = array("status" => "200");
} else {
$response = array("status" => "500");
}
echo json_encode($response);
pg_close($con);
?>