-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadd.php
61 lines (47 loc) · 1.44 KB
/
add.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
<?php
require_once '/app/init.php';
if (!empty($_POST)) {
if (isset($_POST['title'], $_POST['body'], $_POST['keywords'])) {
$title = $_POST['title'];
$body = $_POST['body'];
$keywords = explode(',', $_POST['keywords']);
$indexed = $es->index([
'index' => 'articles',
'type' => 'article',
'body' => [
'title' => $title,
'body' => $body,
'keywords' => $keywords
]
]);
if($indexed) {
print_r($indexed);
}
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Add | ES</title>
<link href="css/main.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<form action="add.php" method="POST" autocomplete="off">
<label>
Title
<input type="text" name="title"> <br>
</label>
<label>
Body
<textarea name="body" rows="8"></textarea> <br>
</label>
<label>
Keywords
<input type="text" name="keywords" placeholder="comma, seprate"> <br>
</label>
<input type="submit" value="Add">
</form>
</body>
</html>