質問編集履歴
2
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
### 前提・実現したいこと
|
2
2
|
|
3
3
|
xfreeでデータベースを用いたポートフォリオをデプロイしたいです。
|
4
|
-
↓現状
|
5
|
-
URL : http://utan.php.xdomain.jp/mini_bbs/join/
|
6
4
|
|
7
5
|
### 発生している問題・エラーメッセージ
|
8
6
|
|
@@ -165,6 +163,4 @@
|
|
165
163
|
こちらを試してみたが、PHPの知識が浅く解決できませんでした。
|
166
164
|
https://secure.xfree.ne.jp/bbs/detail.cgi?td=442
|
167
165
|
|
168
|
-
### 補足情報(FW/ツールのバージョンなど)
|
166
|
+
### 補足情報(FW/ツールのバージョンなど)
|
169
|
-
githubで公開しました。
|
170
|
-
https://github.com/OHMORIYUSUKE/mini_bbs
|
1
修正
title
CHANGED
File without changes
|
body
CHANGED
@@ -24,9 +24,147 @@
|
|
24
24
|
}
|
25
25
|
?>
|
26
26
|
```
|
27
|
+
```ここに言語名を入力
|
28
|
+
<?php
|
29
|
+
session_start();
|
30
|
+
require('../dbconenect.php');
|
27
31
|
|
32
|
+
if(!empty($_POST)){
|
33
|
+
//エラー判定
|
34
|
+
if($_POST['name'] === ''){
|
35
|
+
$errer['name']='blank';
|
36
|
+
}
|
37
|
+
if($_POST['email'] === ''){
|
38
|
+
$errer['email']='blank';
|
39
|
+
}
|
40
|
+
if(strlen($_POST['password']) <4 ){
|
41
|
+
$errer['password']='length';
|
42
|
+
}
|
43
|
+
if($_POST['password'] === ''){
|
44
|
+
$errer['password']='blank';
|
45
|
+
}
|
46
|
+
//画像拡張子判定
|
47
|
+
$fileName = $_FILES['image']['name'];
|
48
|
+
if(!empty($fileName)){
|
49
|
+
$ext = substr($fileName, -3);
|
50
|
+
if($ext != 'jpg' && $ext != 'png' && $ext != 'gif'){
|
51
|
+
$errer['image'] = 'type';
|
52
|
+
}
|
53
|
+
}
|
54
|
+
|
55
|
+
//アカウント重複防止
|
56
|
+
if(empty($error)){
|
57
|
+
$member = $db->prepare('SELECT COUNT(*) AS cnt FROM members WHERE email=?');
|
58
|
+
$member->execute(array($_POST['email']));
|
59
|
+
$recode = $member->fetch();
|
60
|
+
//$recodeは0,1を返す
|
61
|
+
if($recode['cnt'] > 0){
|
62
|
+
$errer['email'] = 'duplicate';
|
63
|
+
}
|
64
|
+
}
|
65
|
+
|
66
|
+
|
67
|
+
if(empty($errer)){
|
68
|
+
//画像保存//現在時刻を付加して名前がかぶらないようにする
|
69
|
+
$image = date('YmdHis').$_FILES['image']['name'];
|
70
|
+
move_uploaded_file($_FILES['image']['tmp_name'],'../member_picture/'.$image);
|
71
|
+
|
72
|
+
$_SESSION['join'] = $_POST;
|
73
|
+
|
74
|
+
$_SESSION['join']['image'] = $image;
|
75
|
+
|
76
|
+
header('Location:check.php');
|
77
|
+
exit();
|
78
|
+
}
|
79
|
+
}
|
80
|
+
//rewriteがurlで渡されたらフォームに入力しておく
|
81
|
+
if($_REQUEST['action'] == 'rewrite'){
|
82
|
+
$_POST = $_SESSION['join'];
|
83
|
+
}
|
84
|
+
?>
|
85
|
+
<!DOCTYPE html>
|
86
|
+
<html lang="ja">
|
87
|
+
<head>
|
88
|
+
<meta charset="UTF-8">
|
89
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
90
|
+
<meta http-equiv="X-UA-Compatible" content="ie=edge">
|
91
|
+
<title>会員登録</title>
|
92
|
+
|
93
|
+
<link rel="stylesheet" href="../style.css" />
|
94
|
+
</head>
|
95
|
+
<body>
|
96
|
+
<div id="wrap">
|
97
|
+
<div id="head">
|
98
|
+
<h1>会員登録</h1>
|
99
|
+
</div>
|
100
|
+
|
101
|
+
<div id="content">
|
102
|
+
<p>次のフォームに必要事項をご記入ください。</p>
|
103
|
+
<form action="" method="post" enctype="multipart/form-data">
|
104
|
+
<dl>
|
105
|
+
<dt>ニックネーム<span class="required">必須</span></dt>
|
106
|
+
<dd>
|
107
|
+
<input type="text" name="name" size="35" maxlength="255" value="<?php print(htmlspecialchars($_POST['name'],ENT_QUOTES)); ?>" />
|
108
|
+
</dd>
|
109
|
+
<?php
|
110
|
+
if ($errer['name'] === 'blank'):
|
111
|
+
?>
|
112
|
+
<p class="error">*ニックネームを入力してください。</p>
|
113
|
+
<?php endif;?>
|
114
|
+
<dt>メールアドレス<span class="required">必須</span></dt>
|
115
|
+
<dd>
|
116
|
+
<input type="text" name="email" size="35" maxlength="255" value="<?php print(htmlspecialchars($_POST['email'],ENT_QUOTES)); ?>" />
|
117
|
+
<?php
|
118
|
+
if ($errer['email'] === 'blank'):
|
119
|
+
?>
|
120
|
+
<p class="error">*メールアドレスを入力してください。</p>
|
121
|
+
<?php endif;?>
|
122
|
+
<?php
|
123
|
+
if ($errer['email'] === 'duplicate'):
|
124
|
+
?>
|
125
|
+
<p class="error">*メールアドレスはすでに登録されています。</p>
|
126
|
+
<?php endif;?>
|
127
|
+
<dt>パスワード<span class="required">必須</span></dt>
|
128
|
+
<dd>
|
129
|
+
<input type="password" name="password" size="10" maxlength="20" value="<?php print(htmlspecialchars($_POST['password'],ENT_QUOTES)); ?>" />
|
130
|
+
</dd>
|
131
|
+
<?php
|
132
|
+
if ($errer['password'] === 'blank'):
|
133
|
+
?>
|
134
|
+
<p class="error">*パスワードを入力してください。</p>
|
135
|
+
<?php endif;?>
|
136
|
+
<?php
|
137
|
+
if ($errer['password'] === 'length'):
|
138
|
+
?>
|
139
|
+
<p class="error">*パスワードが短すぎます。</p>
|
140
|
+
<?php endif;?>
|
141
|
+
<dt>写真など</dt>
|
142
|
+
<dd>
|
143
|
+
<input type="file" name="image" size="35" value="test" />
|
144
|
+
|
145
|
+
<?php
|
146
|
+
if($errer['image'] === 'type'):?>
|
147
|
+
<p class="error">画像のみアップロードできます</p>
|
148
|
+
<?php endif; ?>
|
149
|
+
<?php
|
150
|
+
if(!empty($errer)):
|
151
|
+
?>
|
152
|
+
<p class="error">画像を再度アップロードしてください</p>
|
153
|
+
<?php endif;?>
|
154
|
+
</dd>
|
155
|
+
</dl>
|
156
|
+
<div><input type="submit" value="入力内容を確認する" /></div>
|
157
|
+
</form>
|
158
|
+
</div>
|
159
|
+
</body>
|
160
|
+
</html>
|
161
|
+
|
162
|
+
```
|
163
|
+
|
28
164
|
### 試したこと
|
29
165
|
こちらを試してみたが、PHPの知識が浅く解決できませんでした。
|
30
166
|
https://secure.xfree.ne.jp/bbs/detail.cgi?td=442
|
31
167
|
|
32
|
-
### 補足情報(FW/ツールのバージョンなど)
|
168
|
+
### 補足情報(FW/ツールのバージョンなど)
|
169
|
+
githubで公開しました。
|
170
|
+
https://github.com/OHMORIYUSUKE/mini_bbs
|