質問編集履歴
4
編集しましたー。。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
```php
|
2
2
|
<?php
|
3
3
|
|
4
|
-
if(
|
4
|
+
if(isset($_POST['ques1'])){
|
5
|
-
print("エラー。");
|
6
|
-
} else {
|
7
5
|
$file = @fopen("log.txt","a");
|
8
|
-
fputs($file,"$_POST['
|
6
|
+
fputs($file,"$_POST['ques1']");
|
9
|
-
fwrite($file,"$_POST['
|
7
|
+
fwrite($file,"$_POST['ques1']");
|
10
8
|
fclose($file);
|
9
|
+
} else {
|
10
|
+
print("エラー。");
|
11
11
|
}
|
12
12
|
?>
|
13
13
|
|
@@ -37,9 +37,11 @@
|
|
37
37
|
</html>
|
38
38
|
```
|
39
39
|
|
40
|
-
Parse error: syntax error, unexpected '
|
40
|
+
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in p on line 5
|
41
41
|
|
42
|
-
|
42
|
+
5行目でエラーが出ます。
|
43
43
|
|
44
|
+
if issetで、postされていないから、スルーされるはずのif文内でなぜか出ます。。
|
45
|
+
|
44
46
|
コードにこだわりはないので、したいことができるなら大きく変えて貰って構いません。
|
45
47
|
具体的には、同じページで、フォーム送信し、送信内容を受け取り、書き込む、というものです。
|
3
編集しましたー。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,18 +1,14 @@
|
|
1
1
|
```php
|
2
2
|
<?php
|
3
3
|
|
4
|
-
if
|
4
|
+
if(!$file || isset($_POST['ques1']){
|
5
|
+
print("エラー。");
|
6
|
+
} else {
|
5
|
-
$file = @fopen("log.txt","a");
|
7
|
+
$file = @fopen("log.txt","a");
|
8
|
+
fputs($file,"$_POST['a']");
|
9
|
+
fwrite($file,"$_POST['b']");
|
6
|
-
|
10
|
+
fclose($file);
|
7
|
-
print("ファイルがありません。");
|
8
11
|
}
|
9
|
-
else
|
10
|
-
{
|
11
|
-
fputs($file,"$_POST['a']");
|
12
|
-
fwrite($file,"$_POST['b']");
|
13
|
-
fclose($file);
|
14
|
-
}
|
15
|
-
}
|
16
12
|
?>
|
17
13
|
|
18
14
|
<!doctype html>
|
@@ -25,16 +21,15 @@
|
|
25
21
|
|
26
22
|
<h2><?php echo $title ?></h2>
|
27
23
|
<form method="POST" action="quiz.php">
|
28
|
-
<input type="text" name="a" size="40" maxlength="20">
|
29
|
-
<input type="text" name="b" size="40" maxlength="20">
|
30
|
-
<input type="text" name="c" size="40" maxlength="20">
|
31
|
-
<input type="text" name="d" size="40" maxlength="20">
|
32
|
-
<input type="
|
24
|
+
<input type="test" name="ques1" size="40" maxlength="20">
|
33
|
-
<input type="
|
25
|
+
<input type="test" name="ques2" size="40" maxlength="20">
|
34
|
-
<input type="
|
26
|
+
<input type="test" name="ques3" size="40" maxlength="20">
|
35
|
-
<input type="
|
27
|
+
<input type="test" name="ques4" size="40" maxlength="20">
|
36
|
-
<input type="
|
28
|
+
<input type="test" name="ques5" size="40" maxlength="20">
|
37
|
-
<input type="
|
29
|
+
<input type="test" name="ques6" size="40" maxlength="20">
|
30
|
+
<input type="test" name="ques7" size="40" maxlength="20">
|
31
|
+
<input type="test" name="ques8" size="40" maxlength="20">
|
32
|
+
<input type="test" name="ques9" size="40" maxlength="20">
|
38
33
|
<input type="submit" value="送信する">
|
39
34
|
</form>
|
40
35
|
|
@@ -42,12 +37,9 @@
|
|
42
37
|
</html>
|
43
38
|
```
|
44
39
|
|
45
|
-
|
40
|
+
Parse error: syntax error, unexpected '{' in on line 3
|
46
41
|
|
47
|
-
エラー
|
42
|
+
3行目でエラーが出ます。
|
48
|
-
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in line 10
|
49
43
|
|
50
|
-
エラーが出ます、なぜでしょう。
|
51
|
-
|
52
44
|
コードにこだわりはないので、したいことができるなら大きく変えて貰って構いません。
|
53
45
|
具体的には、同じページで、フォーム送信し、送信内容を受け取り、書き込む、というものです。
|
2
編集致しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -3,14 +3,14 @@
|
|
3
3
|
|
4
4
|
if (isset($_POST['a'])){
|
5
5
|
$file = @fopen("log.txt","a");
|
6
|
-
if(!$file)
|
6
|
+
if(!$file){
|
7
|
-
|
7
|
+
print("ファイルがありません。");
|
8
8
|
}
|
9
9
|
else
|
10
10
|
{
|
11
|
-
|
11
|
+
fputs($file,"$_POST['a']");
|
12
|
-
|
12
|
+
fwrite($file,"$_POST['b']");
|
13
|
-
|
13
|
+
fclose($file);
|
14
14
|
}
|
15
15
|
}
|
16
16
|
?>
|
@@ -19,7 +19,7 @@
|
|
19
19
|
<html>
|
20
20
|
<head>
|
21
21
|
<meta charset="utf-8">
|
22
|
-
<title>ラム</title>
|
22
|
+
<title>簡易クイズプログラム</title>
|
23
23
|
</head>
|
24
24
|
<body>
|
25
25
|
|
1
編集しました。
title
CHANGED
File without changes
|
body
CHANGED
@@ -1,28 +1,43 @@
|
|
1
1
|
```php
|
2
2
|
<?php
|
3
|
-
$text = $_POST['text'];
|
4
|
-
$fp = fopen("log.txt", "a");
|
5
|
-
fwrite($fp, "追記です。");
|
6
|
-
fclose($fp);
|
7
3
|
|
4
|
+
if (isset($_POST['a'])){
|
8
|
-
|
5
|
+
$file = @fopen("log.txt","a");
|
6
|
+
if(!$file)
|
7
|
+
{
|
8
|
+
}
|
9
|
+
else
|
10
|
+
{
|
11
|
+
fputs($file,"$_POST['a']");
|
9
|
-
|
12
|
+
fwrite($file,"$_POST['b']");
|
13
|
+
fclose($file);
|
14
|
+
}
|
15
|
+
}
|
10
16
|
?>
|
11
17
|
|
12
18
|
<!doctype html>
|
13
19
|
<html>
|
14
20
|
<head>
|
15
21
|
<meta charset="utf-8">
|
16
|
-
<title>
|
22
|
+
<title>ラム</title>
|
17
23
|
</head>
|
18
24
|
<body>
|
19
25
|
|
26
|
+
<h2><?php echo $title ?></h2>
|
27
|
+
<form method="POST" action="quiz.php">
|
20
|
-
<
|
28
|
+
<input type="text" name="a" size="40" maxlength="20">
|
29
|
+
<input type="text" name="b" size="40" maxlength="20">
|
30
|
+
<input type="text" name="c" size="40" maxlength="20">
|
31
|
+
<input type="text" name="d" size="40" maxlength="20">
|
21
|
-
|
32
|
+
<input type="text" name="e" size="40" maxlength="20">
|
33
|
+
<input type="text" name="f" size="40" maxlength="20">
|
34
|
+
<input type="text" name="g" size="40" maxlength="20">
|
35
|
+
<input type="text" name="h" size="40" maxlength="20">
|
36
|
+
<input type="text" name="i" size="40" maxlength="20">
|
37
|
+
<input type="text" name="j" size="40" maxlength="20">
|
22
|
-
|
38
|
+
<input type="submit" value="送信する">
|
23
39
|
</form>
|
24
40
|
|
25
|
-
|
26
41
|
</body>
|
27
42
|
</html>
|
28
43
|
```
|
@@ -30,7 +45,7 @@
|
|
30
45
|
こういうコードを書いた(質問後訂正指摘があったので訂正した)のですが、
|
31
46
|
|
32
47
|
エラー内容
|
33
|
-
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in
|
48
|
+
Parse error: syntax error, unexpected '' (T_ENCAPSED_AND_WHITESPACE), expecting identifier (T_STRING) or variable (T_VARIABLE) or number (T_NUM_STRING) in line 10
|
34
49
|
|
35
50
|
エラーが出ます、なぜでしょう。
|
36
51
|
|