質問編集履歴
3
Wordpressのfunction.phpの中で、PHPファイルを呼び出す記述をしていますので、それを、掲載します。
title
CHANGED
File without changes
|
body
CHANGED
@@ -72,6 +72,19 @@
|
|
72
72
|
|
73
73
|
</html>
|
74
74
|
|
75
|
+
|
76
|
+
|
77
|
+
WordPressのfunction.phpの中に、これを記述しています。
|
78
|
+
|
79
|
+
//ショートコードを使ったphpファイルの呼び出し方法
|
80
|
+
function my_php_Include($params = array()) {
|
81
|
+
extract(shortcode_atts(array('file' => 'default'), $params));
|
82
|
+
ob_start();
|
83
|
+
include(STYLESHEETPATH . "/template-parts/$file.php");
|
84
|
+
return ob_get_clean();
|
85
|
+
}
|
86
|
+
add_shortcode('myphp', 'my_php_Include');
|
87
|
+
|
75
88
|
```
|
76
89
|
|
77
90
|
### 試したこと
|
2
ソースコードがややこしかったので、シンプルにしました。このコードで実行しても結果は期待はずれです。WordPress固定ページでは、ショートコードで、PHPファイルを読み出しています。では、
title
CHANGED
File without changes
|
body
CHANGED
@@ -37,107 +37,19 @@
|
|
37
37
|
<html lang="ja">
|
38
38
|
<head>
|
39
39
|
<meta charset="UTF-8">
|
40
|
-
<title>
|
40
|
+
<title>結果</title>
|
41
|
-
<meta name="viewport" content="width=device-width,initial-scale=1">
|
42
41
|
|
43
|
-
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
44
42
|
|
45
|
-
<!-- Global site tag (gtag.js) - Google Analytics -->
|
46
|
-
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-130664081-1"></script>
|
47
|
-
<script>
|
48
|
-
window.dataLayer = window.dataLayer || [];
|
49
|
-
function gtag(){dataLayer.push(arguments);}
|
50
|
-
gtag('js', new Date());
|
51
|
-
|
52
|
-
gtag('config', 'UA-1○○○-1');
|
53
|
-
</script>
|
54
|
-
|
55
|
-
<script>
|
56
|
-
window.addEventListener('message', function(e) {
|
57
|
-
var iframe = $("#parentframe");
|
58
|
-
var eventName = e.data[0];
|
59
|
-
var data = e.data[1];
|
60
|
-
switch(eventName) {
|
61
|
-
case 'setHeight':
|
62
|
-
iframe.height(data);
|
63
|
-
break;
|
64
|
-
}
|
65
|
-
}, false);
|
66
|
-
</script>
|
67
|
-
|
68
|
-
<link rel="preconnect" href="https://fonts.googleapis.com">
|
69
|
-
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
70
|
-
<link href="https://fonts.googleapis.com/css2?family=MonteCarlo&family=Shippori+Mincho+B1&display=swap" rel="stylesheet">
|
71
|
-
|
72
|
-
<style type="text/css">
|
73
|
-
ここは割愛
|
74
|
-
</style>
|
75
|
-
|
76
|
-
|
77
43
|
<?php
|
78
|
-
$shoppass = $_POST['prm1'];
|
79
|
-
|
80
|
-
//入力チェック
|
81
|
-
$errormsg = array();
|
82
|
-
|
83
|
-
//shoppass
|
84
|
-
if ($shoppass == null) {
|
85
|
-
$errormsg[] = "パスワードを入力してください。";
|
86
|
-
}
|
87
|
-
|
88
|
-
if ($shoppass != null){
|
89
|
-
|
90
|
-
$server = "○○○○";
|
91
|
-
$userName = "○○○○";
|
92
|
-
$password = "○○○○";
|
93
|
-
$dbName = "○○○○";
|
94
|
-
|
95
|
-
$mysqli = new mysqli($server, $userName, $password,$dbName);
|
96
|
-
if ($mysqli->connect_error){
|
97
|
-
echo $mysqli->connect_error;
|
98
|
-
exit();
|
99
|
-
}else{
|
100
|
-
$mysqli->set_charset("utf-8");
|
101
|
-
}
|
102
|
-
|
103
|
-
$sql = "SELECT * FROM woma2 where pass = '" . $shoppass . "'";
|
104
|
-
$result = $mysqli -> query($sql);
|
105
|
-
//クエリー失敗
|
106
|
-
if(!$result) {
|
107
|
-
echo $mysqli->error;
|
108
|
-
exit();
|
109
|
-
}
|
110
|
-
//レコード
|
111
|
-
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
|
112
|
-
$chusen_atari =$row["chusen_atari"];
|
113
|
-
|
114
|
-
if($row==0){
|
115
|
-
$errormsg[] = "パスワードが間違っています。<br><br>入力間違いの中で、<br>1(数字のいち)<br>l(小文字のエル)<br>i(小文字のアイ)<br><br>にご注意ください。";
|
116
|
-
}
|
117
|
-
|
118
|
-
}
|
119
|
-
|
120
|
-
?>
|
121
|
-
|
122
|
-
<?php if (count($errormsg) > 0): ?>
|
123
|
-
<div id="errmsg">
|
124
|
-
ERROR<br />
|
125
|
-
<?php foreach ($errormsg as $msg): ?>
|
126
|
-
<?=$msg?><br />
|
127
|
-
<?php endforeach; ?>
|
128
|
-
</div>
|
129
44
|
|
130
|
-
|
45
|
+
$shoppass="2014";
|
46
|
+
|
47
|
+
$server = "○○○○";
|
48
|
+
$userName = "○○○○";
|
49
|
+
$password = "○○○○";
|
50
|
+
$dbName = "○○○○";
|
131
51
|
|
132
|
-
|
133
|
-
<?php
|
134
|
-
|
135
|
-
$server = "○○○○";
|
136
|
-
$userName = "○○○○";
|
137
|
-
$password = "○○○○";
|
138
|
-
$dbName = "○○○○";
|
139
|
-
|
140
|
-
|
52
|
+
$mysqli = new mysqli($server, $userName, $password,$dbName);
|
141
53
|
if ($mysqli->connect_error){
|
142
54
|
echo $mysqli->connect_error;
|
143
55
|
exit();
|
@@ -148,129 +60,18 @@
|
|
148
60
|
$now = date('Y/m/d H:i:s');
|
149
61
|
echo $now;
|
150
62
|
|
151
|
-
|
152
|
-
$sql = "update woma2 set
|
63
|
+
$sql = "update woma2 set use_times = use_times+1 where pass = '" . $shoppass . "'";
|
153
|
-
|
64
|
+
$result = $mysqli -> query($sql);
|
154
|
-
|
155
|
-
//クエリー失敗
|
156
|
-
if(!$result) {
|
157
|
-
echo $mysqli->error;
|
158
|
-
exit();}
|
159
|
-
|
160
|
-
|
161
|
-
$server = "○○○○";
|
162
|
-
$userName = "○○○○";
|
163
|
-
$password = "○○○○";
|
164
|
-
$dbName = "○○○○";
|
165
|
-
|
166
|
-
$mysqli = new mysqli($server, $userName, $password,$dbName);
|
167
|
-
if ($mysqli->connect_error){
|
168
|
-
echo $mysqli->connect_error;
|
169
|
-
exit();
|
170
|
-
}else{
|
171
|
-
$mysqli->set_charset("utf-8");
|
172
|
-
}
|
173
|
-
|
174
|
-
/////■■■■■■■■■■■■■■■ここです■■■■■■■■■■■■■■■
|
175
|
-
$sql = "update woma2 set use_times = use_times+1 where pass = '" . $shoppass . "'";
|
176
|
-
$result = $mysqli -> query($sql);
|
177
65
|
//クエリー失敗
|
178
66
|
if(!$result) {
|
179
67
|
echo $mysqli->error;
|
180
68
|
exit();}
|
181
69
|
|
182
70
|
|
183
|
-
|
184
|
-
$num_rows=0;
|
185
|
-
|
186
|
-
|
187
|
-
// 接続処理
|
188
|
-
$con = mysqli_connect('○○', '○○', '○○', '○○');
|
189
|
-
if(!$con) {
|
190
|
-
die('接続に失敗しました');
|
191
|
-
}
|
192
|
-
|
193
|
-
// 文字コード
|
194
|
-
mysqli_set_charset($con, 'utf8');
|
195
|
-
|
196
|
-
// SQLの発行と出力
|
197
|
-
$sql = "SELECT * FROM woma2 where use_times > 0";
|
198
|
-
$res = mysqli_query($con, $sql);
|
199
|
-
$num_rows = mysqli_num_rows($res);
|
200
|
-
|
201
|
-
echo $num_rows;
|
202
|
-
// 接続断
|
203
|
-
mysqli_close($con);
|
204
|
-
|
205
|
-
|
206
|
-
//100人にひとり当たる
|
207
|
-
//1目は当たる
|
208
|
-
//7人目は当たる
|
209
|
-
if(($num_rows %100 == 0)or($num_rows ==1)or($num_rows ==7)){
|
210
|
-
|
211
|
-
$server = "○○○○";
|
212
|
-
$userName = "○○○○";
|
213
|
-
$password = "○○○○";
|
214
|
-
$dbName = "○○○○";
|
215
|
-
|
216
|
-
$mysqli = new mysqli($server, $userName, $password,$dbName);
|
217
|
-
if ($mysqli->connect_error){
|
218
|
-
echo $mysqli->connect_error;
|
219
|
-
exit();
|
220
|
-
}else{
|
221
|
-
$mysqli->set_charset("utf-8");
|
222
|
-
}
|
223
|
-
|
224
|
-
//この条件のときにchusen_atariを1にする
|
225
|
-
$sql = "update woma2 set chusen_atari=1 where pass = '" . $shoppass . "'";
|
226
|
-
$result = $mysqli -> query($sql);
|
227
|
-
|
228
|
-
|
229
|
-
//クエリー失敗
|
230
|
-
if(!$result) {
|
231
|
-
echo $mysqli->error;
|
232
|
-
exit();}
|
233
|
-
|
234
|
-
}
|
235
|
-
|
236
71
|
?>
|
237
72
|
|
73
|
+
</html>
|
238
74
|
|
239
|
-
|
240
|
-
<!--クーポン当たり-->
|
241
|
-
<?php
|
242
|
-
if($chusen_atari !=1){echo "<!--";}
|
243
|
-
?>
|
244
|
-
|
245
|
-
<div class="p-result">
|
246
|
-
あたりの場合の文書
|
247
|
-
</div>
|
248
|
-
|
249
|
-
|
250
|
-
<?php
|
251
|
-
if($chusen_atari!=1){echo "-->";}
|
252
|
-
?>
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
<!--はずれ-->
|
257
|
-
<?php
|
258
|
-
if($chusen_atari ==1){echo "<!--";}
|
259
|
-
?>
|
260
|
-
|
261
|
-
<div class="p-result">
|
262
|
-
はずれの場合の文書
|
263
|
-
</div>
|
264
|
-
|
265
|
-
<?php
|
266
|
-
if(($chusen_atari ==1)&&($num_rows ==3)){echo "-->";}
|
267
|
-
?>
|
268
|
-
|
269
|
-
|
270
|
-
<?php endif; ?>
|
271
|
-
|
272
|
-
</html>
|
273
|
-
|
274
75
|
```
|
275
76
|
|
276
77
|
### 試したこと
|
1
ソースコードについて、割愛したものの掲載から、できる限り全部掲載しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -33,12 +33,64 @@
|
|
33
33
|
### 該当のソースコード
|
34
34
|
|
35
35
|
```
|
36
|
+
<!DOCTYPE html>
|
37
|
+
<html lang="ja">
|
38
|
+
<head>
|
39
|
+
<meta charset="UTF-8">
|
40
|
+
<title>抽選結果</title>
|
41
|
+
<meta name="viewport" content="width=device-width,initial-scale=1">
|
42
|
+
|
43
|
+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
|
44
|
+
|
45
|
+
<!-- Global site tag (gtag.js) - Google Analytics -->
|
46
|
+
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-130664081-1"></script>
|
47
|
+
<script>
|
48
|
+
window.dataLayer = window.dataLayer || [];
|
49
|
+
function gtag(){dataLayer.push(arguments);}
|
50
|
+
gtag('js', new Date());
|
51
|
+
|
52
|
+
gtag('config', 'UA-1○○○-1');
|
53
|
+
</script>
|
54
|
+
|
55
|
+
<script>
|
56
|
+
window.addEventListener('message', function(e) {
|
57
|
+
var iframe = $("#parentframe");
|
58
|
+
var eventName = e.data[0];
|
59
|
+
var data = e.data[1];
|
60
|
+
switch(eventName) {
|
61
|
+
case 'setHeight':
|
62
|
+
iframe.height(data);
|
63
|
+
break;
|
64
|
+
}
|
65
|
+
}, false);
|
66
|
+
</script>
|
67
|
+
|
68
|
+
<link rel="preconnect" href="https://fonts.googleapis.com">
|
69
|
+
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
|
70
|
+
<link href="https://fonts.googleapis.com/css2?family=MonteCarlo&family=Shippori+Mincho+B1&display=swap" rel="stylesheet">
|
71
|
+
|
72
|
+
<style type="text/css">
|
73
|
+
ここは割愛
|
74
|
+
</style>
|
75
|
+
|
76
|
+
|
36
77
|
<?php
|
37
|
-
|
78
|
+
$shoppass = $_POST['prm1'];
|
79
|
+
|
80
|
+
//入力チェック
|
81
|
+
$errormsg = array();
|
82
|
+
|
83
|
+
//shoppass
|
84
|
+
if ($shoppass == null) {
|
85
|
+
$errormsg[] = "パスワードを入力してください。";
|
86
|
+
}
|
87
|
+
|
88
|
+
if ($shoppass != null){
|
89
|
+
|
38
|
-
$server = "
|
90
|
+
$server = "○○○○";
|
39
91
|
$userName = "○○○○";
|
40
92
|
$password = "○○○○";
|
41
|
-
$dbName = "
|
93
|
+
$dbName = "○○○○";
|
42
94
|
|
43
95
|
$mysqli = new mysqli($server, $userName, $password,$dbName);
|
44
96
|
if ($mysqli->connect_error){
|
@@ -48,17 +100,177 @@
|
|
48
100
|
$mysqli->set_charset("utf-8");
|
49
101
|
}
|
50
102
|
|
51
|
-
|
103
|
+
$sql = "SELECT * FROM woma2 where pass = '" . $shoppass . "'";
|
52
|
-
|
53
|
-
|
104
|
+
$result = $mysqli -> query($sql);
|
54
|
-
|
55
|
-
|
105
|
+
//クエリー失敗
|
56
106
|
if(!$result) {
|
57
107
|
echo $mysqli->error;
|
58
|
-
exit();
|
108
|
+
exit();
|
109
|
+
}
|
110
|
+
//レコード
|
111
|
+
$row = mysqli_fetch_array($result,MYSQLI_ASSOC);
|
112
|
+
$chusen_atari =$row["chusen_atari"];
|
113
|
+
|
114
|
+
if($row==0){
|
115
|
+
$errormsg[] = "パスワードが間違っています。<br><br>入力間違いの中で、<br>1(数字のいち)<br>l(小文字のエル)<br>i(小文字のアイ)<br><br>にご注意ください。";
|
116
|
+
}
|
117
|
+
|
118
|
+
}
|
119
|
+
|
120
|
+
?>
|
121
|
+
|
122
|
+
<?php if (count($errormsg) > 0): ?>
|
123
|
+
<div id="errmsg">
|
124
|
+
ERROR<br />
|
125
|
+
<?php foreach ($errormsg as $msg): ?>
|
126
|
+
<?=$msg?><br />
|
127
|
+
<?php endforeach; ?>
|
128
|
+
</div>
|
59
129
|
|
130
|
+
<?php else: ?>
|
131
|
+
|
132
|
+
|
133
|
+
<?php
|
134
|
+
|
135
|
+
$server = "○○○○";
|
136
|
+
$userName = "○○○○";
|
137
|
+
$password = "○○○○";
|
138
|
+
$dbName = "○○○○";
|
139
|
+
|
140
|
+
$mysqli = new mysqli($server, $userName, $password,$dbName);
|
141
|
+
if ($mysqli->connect_error){
|
142
|
+
echo $mysqli->connect_error;
|
143
|
+
exit();
|
144
|
+
}else{
|
145
|
+
$mysqli->set_charset("utf-8");
|
146
|
+
}
|
147
|
+
|
148
|
+
$now = date('Y/m/d H:i:s');
|
149
|
+
echo $now;
|
150
|
+
|
151
|
+
|
152
|
+
$sql = "update woma2 set date_use_pass = '" . $now . "' where pass = '" . $shoppass . "'";
|
153
|
+
$result = $mysqli -> query($sql);
|
154
|
+
|
155
|
+
//クエリー失敗
|
156
|
+
if(!$result) {
|
157
|
+
echo $mysqli->error;
|
158
|
+
exit();}
|
159
|
+
|
160
|
+
|
161
|
+
$server = "○○○○";
|
162
|
+
$userName = "○○○○";
|
163
|
+
$password = "○○○○";
|
164
|
+
$dbName = "○○○○";
|
165
|
+
|
166
|
+
$mysqli = new mysqli($server, $userName, $password,$dbName);
|
167
|
+
if ($mysqli->connect_error){
|
168
|
+
echo $mysqli->connect_error;
|
169
|
+
exit();
|
170
|
+
}else{
|
171
|
+
$mysqli->set_charset("utf-8");
|
172
|
+
}
|
173
|
+
|
174
|
+
/////■■■■■■■■■■■■■■■ここです■■■■■■■■■■■■■■■
|
175
|
+
$sql = "update woma2 set use_times = use_times+1 where pass = '" . $shoppass . "'";
|
176
|
+
$result = $mysqli -> query($sql);
|
177
|
+
//クエリー失敗
|
178
|
+
if(!$result) {
|
179
|
+
echo $mysqli->error;
|
180
|
+
exit();}
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
$num_rows=0;
|
185
|
+
|
186
|
+
|
187
|
+
// 接続処理
|
188
|
+
$con = mysqli_connect('○○', '○○', '○○', '○○');
|
189
|
+
if(!$con) {
|
190
|
+
die('接続に失敗しました');
|
191
|
+
}
|
192
|
+
|
193
|
+
// 文字コード
|
194
|
+
mysqli_set_charset($con, 'utf8');
|
195
|
+
|
196
|
+
// SQLの発行と出力
|
197
|
+
$sql = "SELECT * FROM woma2 where use_times > 0";
|
198
|
+
$res = mysqli_query($con, $sql);
|
199
|
+
$num_rows = mysqli_num_rows($res);
|
200
|
+
|
201
|
+
echo $num_rows;
|
202
|
+
// 接続断
|
203
|
+
mysqli_close($con);
|
204
|
+
|
205
|
+
|
206
|
+
//100人にひとり当たる
|
207
|
+
//1目は当たる
|
208
|
+
//7人目は当たる
|
209
|
+
if(($num_rows %100 == 0)or($num_rows ==1)or($num_rows ==7)){
|
210
|
+
|
211
|
+
$server = "○○○○";
|
212
|
+
$userName = "○○○○";
|
213
|
+
$password = "○○○○";
|
214
|
+
$dbName = "○○○○";
|
215
|
+
|
216
|
+
$mysqli = new mysqli($server, $userName, $password,$dbName);
|
217
|
+
if ($mysqli->connect_error){
|
218
|
+
echo $mysqli->connect_error;
|
219
|
+
exit();
|
220
|
+
}else{
|
221
|
+
$mysqli->set_charset("utf-8");
|
222
|
+
}
|
223
|
+
|
224
|
+
//この条件のときにchusen_atariを1にする
|
225
|
+
$sql = "update woma2 set chusen_atari=1 where pass = '" . $shoppass . "'";
|
226
|
+
$result = $mysqli -> query($sql);
|
227
|
+
|
228
|
+
|
229
|
+
//クエリー失敗
|
230
|
+
if(!$result) {
|
231
|
+
echo $mysqli->error;
|
232
|
+
exit();}
|
233
|
+
|
234
|
+
}
|
235
|
+
|
60
236
|
?>
|
61
237
|
|
238
|
+
|
239
|
+
|
240
|
+
<!--クーポン当たり-->
|
241
|
+
<?php
|
242
|
+
if($chusen_atari !=1){echo "<!--";}
|
243
|
+
?>
|
244
|
+
|
245
|
+
<div class="p-result">
|
246
|
+
あたりの場合の文書
|
247
|
+
</div>
|
248
|
+
|
249
|
+
|
250
|
+
<?php
|
251
|
+
if($chusen_atari!=1){echo "-->";}
|
252
|
+
?>
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
<!--はずれ-->
|
257
|
+
<?php
|
258
|
+
if($chusen_atari ==1){echo "<!--";}
|
259
|
+
?>
|
260
|
+
|
261
|
+
<div class="p-result">
|
262
|
+
はずれの場合の文書
|
263
|
+
</div>
|
264
|
+
|
265
|
+
<?php
|
266
|
+
if(($chusen_atari ==1)&&($num_rows ==3)){echo "-->";}
|
267
|
+
?>
|
268
|
+
|
269
|
+
|
270
|
+
<?php endif; ?>
|
271
|
+
|
272
|
+
</html>
|
273
|
+
|
62
274
|
```
|
63
275
|
|
64
276
|
### 試したこと
|