-
Notifications
You must be signed in to change notification settings - Fork 0
/
camp.php
76 lines (62 loc) · 1.54 KB
/
camp.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
<!DOCTYPE html>
<html>
<head>
<script src="jquery.min.js" ></script>
</head>
<body>
<!-- opens db connection-->
<?php
class MyDB extends SQLite3
{
function __construct()
{
$this->open('db/test.db');
}
}
$db = new MyDB();
?>
<form id="myform" method="post">
<p>Your id: <input type="text" id="id" name="id" /></p>
<p>Your name: <input type="text" id="name" name="name" /></p>
<p>Your message: <input type="text" id="message" name="message" /></p>
<p><input type="submit" /></p>
</form>
<button onclick="viewdata()" id="view">view</button><br>
<script>
$(document).ready(function(){
$("button#view").mouseenter(function () {
var id = $("#id").val();
if (id) {
$.get( "view.php", { id: id }, function(data) {alert( "done: " + data.toString());});
}
});
$("form#myform").submit(function(event) {
event.preventDefault();
var id = $("#id").val();
var name = $("#name").val();
var message = $("#message").val();
$.ajax({
type: "POST",
url: "insert.php",
data: "id=" + id + "&name=" + name + "&message=" + message,
success: function(){alert('success');}
});
});
});
</script>
<!-- lists entries-->
<?php
$sql =<<<EOF
SELECT * from BRICKS;
EOF;
$ret = $db->query($sql);
while($row = $ret->fetchArray(SQLITE3_ASSOC) ){
echo "ID = ". $row['ID'];
echo "NAME = ". $row['NAME'];
echo "MESSAGE = ". $row['MESSAGE'];
echo "<br>";
}
$db->close();
?>
</body>
</html>