-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathaddArticle.php
More file actions
77 lines (58 loc) · 1.74 KB
/
addArticle.php
File metadata and controls
77 lines (58 loc) · 1.74 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
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
<!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"></script>
<body>
<div id="wrap">
<div id="main">
<form method="post" action="addArticle.php">
<label for="title">Title:</label>
<input type="text" id="title" name="title" /><br />
<label for="body">Body:</label>
<textarea id="body" name="body" rows = 10></textarea><br />
<input type="submit" value="Publish" name="submit" />
</form>
<?php
$couch_dsn = "http://localhost:5984/";
$couch_db = "nosql";
/**
* include the library
*/
require_once "couch.php";
require_once "couchClient.php";
require_once "couchDocument.php";
/**
* create the client
*/
$client = new couchClient($couch_dsn,$couch_db);
if (isset($_POST['title']))
{
$title = $_POST['title'];
$body = $_POST['body'];
echo "<p> Added $title</p>";
/* create a new task document */
$article = new StdClass();
$article->_id = $title;
$article->title = $title;
$article->body = $body;
/* now try to insert it */
try {
$response = $client->storeDoc($article);
} catch (Exception $e) {
echo "Error: ".$e->getMessage()." (errcode=".$e->getCode().")\n";
exit(1);
}
#print_r($response);
}
?>
<button style="width:65; height:65" onClick="window.location='http://localhost/noSQL/index.php'">See all Articles</button>
</table>
</div>
</div>
</body>
</html>