-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy patheditCouchDBdocument.php
38 lines (26 loc) · 973 Bytes
/
editCouchDBdocument.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
<?php include_once 'CouchDBusernamepassword.php';
if ($_SERVER["REQUEST_METHOD"] == "POST") {
//if($_POST['update']) {
$ch = curl_init();
$personDetails = array(
'nric' => $_POST["updatenric"],
'name' => $_POST["updateName"],
'mobileNum' => $_POST["updatemobileNum"]
);
$personDetails['_rev'] = $_POST["rev"];
$person = json_encode($personDetails);
curl_setopt($ch, CURLOPT_URL, 'http://localhost:5984/'.$_POST["databaseSelected"]. '/' .$personDetails['nric']);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS, $person);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-type: application/json',
'Accept: /',
));
curl_setopt($ch, CURLOPT_USERPWD, $username.':'.$password);
$response = curl_exec($ch);
echo $response;
curl_close($ch);
header("Location: documents.php?message=editDocumentSuccess&database=".$_POST["databaseSelected"]);
}
?>