質問編集履歴
1
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -62,6 +62,158 @@
|
|
62
62
|
|
63
63
|
|
64
64
|
|
65
|
+
なお、フォームhtmlと登録用のphpファイルは以下の通りです。
|
66
|
+
|
67
|
+
utf8の設定はしているつもりなのですが。
|
68
|
+
|
69
|
+
|
70
|
+
|
71
|
+
present.html
|
72
|
+
|
73
|
+
```ここに言語を入力
|
74
|
+
|
75
|
+
<!DOCTYPE html>
|
76
|
+
|
77
|
+
<html lang="ja">
|
78
|
+
|
79
|
+
<head>
|
80
|
+
|
81
|
+
<meta charset="utf-8">
|
82
|
+
|
83
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
84
|
+
|
85
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
86
|
+
|
87
|
+
<title>プレゼントフォーム</title>
|
88
|
+
|
89
|
+
<link href="css/bootstrap.min.css" rel="stylesheet">
|
90
|
+
|
91
|
+
<link rel="stylesheet" type="text/css" href="form.css" >
|
92
|
+
|
93
|
+
<script src="js/bootstrap.min.js"></script>
|
94
|
+
|
95
|
+
</head>
|
96
|
+
|
97
|
+
<body>
|
98
|
+
|
99
|
+
<form action="present.php" method="post" name="sample" class="form" align="left">
|
100
|
+
|
101
|
+
<div class="form-group">
|
102
|
+
|
103
|
+
商品名
|
104
|
+
|
105
|
+
<input type="text" name="name" placeholder="商品名" class="form-control" required>
|
106
|
+
|
107
|
+
</div>
|
108
|
+
|
109
|
+
<div class="form-group">
|
110
|
+
|
111
|
+
商品説明<br>
|
112
|
+
|
113
|
+
<TEXTAREA name="introduce" maxlength="150" cols="40" rows="6" wrap="off" required></TEXTAREA>
|
114
|
+
|
115
|
+
</div>
|
116
|
+
|
117
|
+
<div class="form-group">
|
118
|
+
|
119
|
+
画像ファイル名
|
120
|
+
|
121
|
+
<input type="text" name="gazou" placeholder="半角英数、jpg/pngのみ" required>
|
122
|
+
|
123
|
+
</div>
|
124
|
+
|
125
|
+
<div class="form-group">
|
126
|
+
|
127
|
+
会社名
|
128
|
+
|
129
|
+
<input type="text" name="companyname" placeholder="会社名" class="form-control" required maxlength="2">
|
130
|
+
|
131
|
+
</div>
|
132
|
+
|
133
|
+
<div class="form-group">
|
134
|
+
|
135
|
+
URL
|
136
|
+
|
137
|
+
<input type="url" name="url" value="" class="form-control">
|
138
|
+
|
139
|
+
</div>
|
140
|
+
|
141
|
+
<button type="submit" class="btn btn-default registration">登録</button>
|
142
|
+
|
143
|
+
</div>
|
144
|
+
|
145
|
+
</form>
|
146
|
+
|
147
|
+
</body>
|
148
|
+
|
149
|
+
</html>
|
150
|
+
|
151
|
+
```
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
present.php
|
156
|
+
|
157
|
+
```ここに言語を入力
|
158
|
+
|
159
|
+
<html>
|
160
|
+
|
161
|
+
<head>
|
162
|
+
|
163
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
164
|
+
|
165
|
+
<title>プレゼント登録</title>
|
166
|
+
|
167
|
+
</head>
|
168
|
+
|
169
|
+
<body>
|
170
|
+
|
171
|
+
<?php
|
172
|
+
|
173
|
+
try{
|
174
|
+
|
175
|
+
$db = new PDO('mysql:host=localhost;dbname=2017_t_autumn;charset=utf8','root','');
|
176
|
+
|
177
|
+
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
178
|
+
|
179
|
+
$ftt=$db->prepare('INSERT INTO present2(name,introduce,gazou,companyname,url)
|
180
|
+
|
181
|
+
VALUES(:name,:introduce,:gazou,:companyname,:url)');
|
182
|
+
|
183
|
+
$ftt->bindValue(':name',$_POST['name']);
|
184
|
+
|
185
|
+
$ftt->bindValue(':introduce',$_POST['introduce']);
|
186
|
+
|
187
|
+
$ftt->bindValue(':gazou',$_POST['gazou']);
|
188
|
+
|
189
|
+
$ftt->bindValue(':companyname',$_POST['companyname']);
|
190
|
+
|
191
|
+
$ftt->bindValue(':url',$_POST['url']);
|
192
|
+
|
193
|
+
$ftt->execute();
|
194
|
+
|
195
|
+
$db = NULL;
|
196
|
+
|
197
|
+
}catch(PDOException $e){
|
198
|
+
|
199
|
+
die('エラーメッセージ:'.$e->getMessage());
|
200
|
+
|
201
|
+
}
|
202
|
+
|
203
|
+
?>
|
204
|
+
|
205
|
+
<p>登録が完了しました。<br /><a href='first.html'>戻る</a></p>
|
206
|
+
|
207
|
+
</body>
|
208
|
+
|
209
|
+
</html>
|
210
|
+
|
211
|
+
```
|
212
|
+
|
213
|
+
|
214
|
+
|
215
|
+
|
216
|
+
|
65
217
|
ぜひ、お知恵をお借りできますと幸いです。
|
66
218
|
|
67
219
|
何卒よろしくお願いいたします。
|