質問編集履歴
1
コードの追加
title
CHANGED
|
File without changes
|
body
CHANGED
|
@@ -30,5 +30,81 @@
|
|
|
30
30
|
②新しいテーブルやデータベースを作って(既存のコピー)データを入力するも同じ
|
|
31
31
|
|
|
32
32
|
|
|
33
|
+
なお、フォームhtmlと登録用のphpファイルは以下の通りです。
|
|
34
|
+
utf8の設定はしているつもりなのですが。
|
|
35
|
+
|
|
36
|
+
present.html
|
|
37
|
+
```ここに言語を入力
|
|
38
|
+
<!DOCTYPE html>
|
|
39
|
+
<html lang="ja">
|
|
40
|
+
<head>
|
|
41
|
+
<meta charset="utf-8">
|
|
42
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
43
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
44
|
+
<title>プレゼントフォーム</title>
|
|
45
|
+
<link href="css/bootstrap.min.css" rel="stylesheet">
|
|
46
|
+
<link rel="stylesheet" type="text/css" href="form.css" >
|
|
47
|
+
<script src="js/bootstrap.min.js"></script>
|
|
48
|
+
</head>
|
|
49
|
+
<body>
|
|
50
|
+
<form action="present.php" method="post" name="sample" class="form" align="left">
|
|
51
|
+
<div class="form-group">
|
|
52
|
+
商品名
|
|
53
|
+
<input type="text" name="name" placeholder="商品名" class="form-control" required>
|
|
54
|
+
</div>
|
|
55
|
+
<div class="form-group">
|
|
56
|
+
商品説明<br>
|
|
57
|
+
<TEXTAREA name="introduce" maxlength="150" cols="40" rows="6" wrap="off" required></TEXTAREA>
|
|
58
|
+
</div>
|
|
59
|
+
<div class="form-group">
|
|
60
|
+
画像ファイル名
|
|
61
|
+
<input type="text" name="gazou" placeholder="半角英数、jpg/pngのみ" required>
|
|
62
|
+
</div>
|
|
63
|
+
<div class="form-group">
|
|
64
|
+
会社名
|
|
65
|
+
<input type="text" name="companyname" placeholder="会社名" class="form-control" required maxlength="2">
|
|
66
|
+
</div>
|
|
67
|
+
<div class="form-group">
|
|
68
|
+
URL
|
|
69
|
+
<input type="url" name="url" value="" class="form-control">
|
|
70
|
+
</div>
|
|
71
|
+
<button type="submit" class="btn btn-default registration">登録</button>
|
|
72
|
+
</div>
|
|
73
|
+
</form>
|
|
74
|
+
</body>
|
|
75
|
+
</html>
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
present.php
|
|
79
|
+
```ここに言語を入力
|
|
80
|
+
<html>
|
|
81
|
+
<head>
|
|
82
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
83
|
+
<title>プレゼント登録</title>
|
|
84
|
+
</head>
|
|
85
|
+
<body>
|
|
86
|
+
<?php
|
|
87
|
+
try{
|
|
88
|
+
$db = new PDO('mysql:host=localhost;dbname=2017_t_autumn;charset=utf8','root','');
|
|
89
|
+
$db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING);
|
|
90
|
+
$ftt=$db->prepare('INSERT INTO present2(name,introduce,gazou,companyname,url)
|
|
91
|
+
VALUES(:name,:introduce,:gazou,:companyname,:url)');
|
|
92
|
+
$ftt->bindValue(':name',$_POST['name']);
|
|
93
|
+
$ftt->bindValue(':introduce',$_POST['introduce']);
|
|
94
|
+
$ftt->bindValue(':gazou',$_POST['gazou']);
|
|
95
|
+
$ftt->bindValue(':companyname',$_POST['companyname']);
|
|
96
|
+
$ftt->bindValue(':url',$_POST['url']);
|
|
97
|
+
$ftt->execute();
|
|
98
|
+
$db = NULL;
|
|
99
|
+
}catch(PDOException $e){
|
|
100
|
+
die('エラーメッセージ:'.$e->getMessage());
|
|
101
|
+
}
|
|
102
|
+
?>
|
|
103
|
+
<p>登録が完了しました。<br /><a href='first.html'>戻る</a></p>
|
|
104
|
+
</body>
|
|
105
|
+
</html>
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
|
|
33
109
|
ぜひ、お知恵をお借りできますと幸いです。
|
|
34
110
|
何卒よろしくお願いいたします。
|