質問編集履歴
3
細かい修正
title
CHANGED
File without changes
|
body
CHANGED
File without changes
|
2
OSの情報追記、登録処理の追記、phpmyadminのinsert処理の追記
title
CHANGED
File without changes
|
body
CHANGED
@@ -11,8 +11,53 @@
|
|
11
11
|
送信された内容が文字化けしてしまいます。
|
12
12
|

|
13
13
|
|
14
|
-
また、
|
14
|
+
また、ソースコードは、以下の通りです。
|
15
|
+
```
|
16
|
+
// 登録処理
|
17
|
+
$link = mysqli_connect('localhost', 'root', '');
|
18
|
+
if(!$link){
|
19
|
+
die('cannot connect database: '.mysqli_error());
|
20
|
+
}
|
21
|
+
|
22
|
+
mysqli_select_db($link,'online_bbs');
|
23
|
+
|
24
|
+
$errors = array();
|
25
|
+
|
26
|
+
if($_SERVER['REQUEST_METHOD'] === 'POST'){
|
27
|
+
$name = null;
|
28
|
+
if(!isset($_POST['name']) || !strlen($_POST['name'])){
|
29
|
+
$errors['name'] = 'Please write your name.';
|
30
|
+
} else if(strlen($_POST['name']) > 40){
|
31
|
+
$errors['name'] = 'Please write your name in 40.';
|
32
|
+
} else {
|
33
|
+
$name = $_POST['name'];
|
34
|
+
}
|
35
|
+
echo $_POST['name']."<br>"; // 確認用
|
36
|
+
|
37
|
+
$comment = null;
|
38
|
+
if(!isset($_POST['comment']) || !strlen($_POST['comment'])){
|
39
|
+
$errors['comment'] = 'Please write comment.';
|
40
|
+
} else if(strlen($_POST['comment']) > 200){
|
41
|
+
$errors['comment'] = 'Please write comment in 200.';
|
42
|
+
} else{
|
43
|
+
$comment = $_POST['comment'];
|
44
|
+
}
|
45
|
+
|
46
|
+
echo $_POST['comment']; // 確認用
|
47
|
+
|
48
|
+
if(count($errors) === 0){
|
49
|
+
$sql = "insert into `post` (`name`, `comment`, `created_at`)";
|
50
|
+
$sql .= "values('". mysqli_real_escape_string($link, $name)."',";
|
51
|
+
$sql .= "'". mysqli_real_escape_string($link, $comment)."',";
|
52
|
+
$sql .= "'". date('Y-m-d H:i:s')."')";
|
53
|
+
|
54
|
+
mysqli_query($link, $sql);
|
55
|
+
}
|
56
|
+
}
|
57
|
+
?>
|
58
|
+
|
59
|
+
/* フォーム */
|
15
|
-
|
60
|
+
<html lang="ja">
|
16
61
|
<head>
|
17
62
|
<meta http-equiv="content-type" content="test/html" charset="utf-8">
|
18
63
|
<title>BBS</title>
|
@@ -28,6 +73,9 @@
|
|
28
73
|
</html>
|
29
74
|
```
|
30
75
|
|
76
|
+
phpmyadminでinsert処理をしたところ、以下の画像のようになりました。
|
77
|
+

|
78
|
+
|
31
79
|
php.iniの設定は、
|
32
80
|
- mbstring.language = Japanese
|
33
81
|
- mbstring.internal_encoding = UTF-8
|
@@ -41,4 +89,5 @@
|
|
41
89
|
|
42
90
|
MySQLのバージョン情報
|
43
91
|

|
92
|
+
OS Windows8.1
|
44
93
|
PHPバージョン 7.3.1
|
1
バージョンの情報追加
title
CHANGED
File without changes
|
body
CHANGED
@@ -37,4 +37,8 @@
|
|
37
37
|
- mbstring.detect_order = auto
|
38
38
|
|
39
39
|
です。
|
40
|
-
何か忘れている設定などがあれば、ご教授いただきたいです。
|
40
|
+
何か忘れている設定などがあれば、ご教授いただきたいです。
|
41
|
+
|
42
|
+
MySQLのバージョン情報
|
43
|
+

|
44
|
+
PHPバージョン 7.3.1
|