-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport.php
94 lines (64 loc) · 1.93 KB
/
report.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>toDo</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
<script type="text/javascript" src="calendarDateInput.js" />
<body>
<div id="wrap">
<div id="main">
<form method="post" action="report.php">
<label for="item">Task:</label>
<input type="text" id="item" name="item" /><br />
<label for="priority">priority:</label>
<input type="text" id="priority" name="priority" /><br />
<input type="submit" value="add" name="submit" />
</form>
<?php
$couch_dsn = "http://localhost:5984/";
$couch_db = "example";
/**
* include the library
*/
require_once "../lib/couch.php";
require_once "../lib/couchClient.php";
require_once "../lib/couchDocument.php";
/**
* create the client
*/
$client = new couchClient($couch_dsn,$couch_db);
if (isset($_POST['item']))
{
$task = $_POST['item'];
$priority = $_POST['priority'];
echo $task;
/* create a new task document */
$todoTask = new StdClass();
$todoTask->_id = $task;
$todoTask->task = $task;
$todoTask->priority = $priority;
/* now try to insert it */
try {
$response = $client->storeDoc($todoTask);
} catch (Exception $e) {
echo "Error: ".$e->getMessage()." (errcode=".$e->getCode().")\n";
exit(1);
}
print_r($response);
}
$all_docs = $client->getAllDocs();
echo "Database got ".$all_docs->total_rows." documents.<BR>\n";
foreach ( $all_docs->rows as $row ) {
echo "".$row->id."<BR>\n";
/* this just gets an id so need to retrieve document */
$doc = $client->getDoc($row->id);
echo $doc->priority;
}
?>
</div>
</div>
</body>
</html>