-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsubmitapplication.php
More file actions
34 lines (28 loc) · 1.15 KB
/
submitapplication.php
File metadata and controls
34 lines (28 loc) · 1.15 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
27
28
29
30
31
32
33
34
<?php
require "../configs/config.php";
require "./common.php";
try {
$connection = new PDO($dsn, $username, $password, $options);
$new_application = array(
"name" => escape($_POST['name']),
"phone" => escape($_POST['phone']),
"email" => escape($_POST['email']),
"address" => escape($_POST['address']),
"currentPets" => escape($_POST['currentPets']),
"currentPetDetails" => escape($_POST['currentPetDetails']),
"animal" => escape($_POST['animal']),
"comments" => escape($_POST['comments'])
);
$sql = sprintf(
"INSERT INTO %s (%s) values (%s)",
"application",
implode(", ", array_keys($new_application)),
":" . implode(", :", array_keys($new_application)));
$statement = $connection->prepare($sql);
$statement->execute($new_application);
header ("location: /index.php");
}
catch(PDOException $error) {
echo $sql . "<br>" . $error->getMessage();
}
?>