/
index.php
156 lines (123 loc) · 3.99 KB
/
index.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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
<?php
require('dbconnct.php');
require('function.php');
date_default_timezone_set('Asia/Tokyo');
$title = '';
$errors = array();
if (!empty($_POST)) {
$title = $_POST['title'];
v($title);
if ($title == '') {
$errors['title'] = 'blank';
}
if (empty($errors)) {
// データーベース登録
$sql = 'INSERT INTO `diary` SET `title` =?, `created` =NOW()';
$data = array($title);
$stmt = $dbh->prepare($sql);
$stmt->execute($data);
header('Location: index.php');
exit();
}
}
$sql = 'DELETE FROM `diary` WHERE id=?';
$data =[$_REQUEST['id']];
$stmt = $dbh->prepare($sql);
$stmt->execute($data);
$sql = 'SELECT * FROM `diary`';
$stmt = $dbh->prepare($sql);
$stmt->execute();
while ($record = $stmt->fetch(PDO::FETCH_ASSOC)) {
$tweets[] = $record;
}
$count = count($tweets);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="assets/css/bootstrap.css">
<link rel="stylesheet" href="assets/font-awesome/css/font-awesome.css">
<link rel="stylesheet" type="text/css" href="assets/css/index.css">
<link rel="stylesheet" href="http://fontawesome.io/assets/font-awesome/css/font-awesome.css">
<!-- <link rel="stylesheet" type="text/css" href="index.js"> -->
<title>Nexeed Training</title>
<script type="text/javascript">
<!--
function check(){
if(window.confirm('削除してよろしいですか?')){ // 確認ダイアログを表示
document.getElementById("frmC");
return true; // 「OK」時は送信を実行
}
else{ // 「キャンセル」時の処理
window.alert('キャンセルされました'); // 警告ダイアログを表示
return false; // 送信を中止
}
}
// -->
</script>
</head>
<body>
<div class=""><h1 class="header" style="margin: 0px auto 10px auto;height: 80px ; line-height: 80px;">
NxSeed Diary</h1>
</div>
<div class="container-fild">
<div class="row">
<div class="col-xs-3">
<!-- <div class="col-xs-3 col-sm-3 col-xs-6"> -->
<div class="main-left">
<?php
$time = intval(date('H'));
if (6 <= $time && $time <= 11) { // 6~11の時間帯のとき ?>
<p class="konnitiwa">おはようございます、ゲストさん</p>
<?php } elseif (11 <= $time && $time <= 18) { // 11:01〜17:59の時間帯のとき ?>
<p class="konnitiwa">こんにちわ、ゲストさん。</p>
<?php } else { // それ以外の時間帯のとき ?>
<p class="konnitiwa">こんばんわ、ゲストさん。</p>
<?php } ?>
<hr>
<div class="date">
<a href=""><?php echo date("Y年m月");?>の日記</a>
</div>
<hr>
<div class="date">
<a href=""><?php echo date("Y年m月",strtotime('-1 month'));?>の日記</a>
</div>
<hr>
<div class="date">
<a href=""><?php echo date("Y年m月",strtotime('-2 month'));?>の日記</a>
</div>
<hr>
<div class="widget-area no-padding blank">
<div class="status-upload">
<form action="index.php" method="POST">
<textarea placeholder="What are you doing right now?" name="title" ></textarea>
<button type="submit" class="btn btn-success green"><i class="fa fa-share"></i> Share</button>
<?php if (isset($errors['title']) && $errors['title'] == 'blank') { ?>
<p class="error">何か入力してください。</p>
<?php } ?>
</form>
</div><!-- Status Upload -->
</div><!-- Widget Area -->
</div>
</div>
<form action="#" method="POST" id="frmC">
<div class="col-xs-9">
<?php for ($i=0; $i < $count; $i++) { ?>
<!-- <div class="col-xs-9 col-sm-9 col-xs-6"> -->
<div class="main-right">
<a href=""><h4><?php echo $tweets[$i]['title']; ?></h4></a>
<p><?php echo $tweets[$i]['created'];?></p>
<a href="index.php?id=<?php echo $tweets[$i]['id']; ?>
" class="btn btn-danger" onclick="check();return false;">削除</a>
</div>
<?php } ?>
</div>
</form>
</div>
<div class="col-sm-12 col-xs-12">
<div class="footer">Copyright NexSeed inc All Rights Reserved.</div>
</div>
</div>
</body>
</html>