質問編集履歴

2

インデントをつけました

2019/12/04 09:18

投稿

TeamPassionall
TeamPassionall

スコア80

test CHANGED
File without changes
test CHANGED
@@ -8,15 +8,13 @@
8
8
 
9
9
  どこがいけないのでしょうか?
10
10
 
11
-
12
-
13
11
  ```php
14
12
 
15
13
 
16
14
 
17
15
  <?php
18
16
 
19
- ini_set( 'display_errors', 1 );
17
+ ini_set('display_errors', 1);
20
18
 
21
19
  error_reporting(E_ALL);
22
20
 
@@ -28,39 +26,39 @@
28
26
 
29
27
 
30
28
 
31
- if(!isset($_SESSION['user'])){
29
+ if (!isset($_SESSION['user'])) {
32
30
 
33
- if(isset($_POST['pass'])){
31
+ if (isset($_POST['pass'])) {
34
32
 
35
- print_r($_POST);
33
+ print_r($_POST);
36
34
 
37
- if(file_exists ('./pass/'.$_POST['user'].'.txt')){
35
+ if (file_exists('./pass/' . $_POST['user'] . '.txt')) {
38
36
 
39
- $pass = readfile('./pass/'.$_POST['user'].'.txt');
37
+ $pass = readfile('./pass/' . $_POST['user'] . '.txt');
40
38
 
39
+
41
40
 
41
+ if ($_POST['pass'] == $pass) {
42
42
 
43
- if($_POST['pass'] == $pass){
43
+
44
44
 
45
+ $_SESSION['user'] = $_POST['user'];
45
46
 
47
+
46
48
 
47
- $_SESSION['user'] = $_POST['user'];
49
+ header("Location: " . $_SERVER['PHP_SELF']);
48
50
 
51
+
49
52
 
53
+ } else {
50
54
 
51
- header("Location: ".$_SERVER['PHP_SELF']);
55
+
52
56
 
57
+
53
58
 
59
+ echo "password incorrect.";
54
60
 
55
- }else{
56
-
57
-
58
-
59
-
60
-
61
- echo"password incorrect.";
62
-
63
- echo'<form action="index.php" method="post">
61
+ echo '<form action="index.php" method="post">
64
62
 
65
63
  <p>
66
64
 
@@ -78,31 +76,31 @@
78
76
 
79
77
  </form>';
80
78
 
81
- exit();
79
+ exit();
82
80
 
83
- }
81
+ }
84
82
 
85
- }else{
83
+ } else {
86
84
 
85
+
87
86
 
87
+ file_put_contents("./pass/" . $_post['user'] . ".txt", $_post['pass']);
88
88
 
89
- file_put_contents("./pass/".$_post['user'].".txt", $_post['pass']);
89
+
90
90
 
91
+ header("Location: " . $_SERVER['PHP_SELF']);
91
92
 
93
+
92
94
 
93
- header("Location: ".$_SERVER['PHP_SELF']);
95
+ }
94
96
 
97
+ } else {
95
98
 
99
+
96
100
 
97
- }
101
+ echo "login";
98
102
 
99
- }else{
100
-
101
-
102
-
103
- echo"login";
104
-
105
- echo'<form action="index.php" method="post">
103
+ echo '<form action="index.php" method="post">
106
104
 
107
105
  <p>
108
106
 
@@ -120,19 +118,19 @@
120
118
 
121
119
  </form>';
122
120
 
123
- exit();
121
+ exit();
124
122
 
123
+
125
124
 
125
+ }
126
126
 
127
- }
127
+ } else {
128
128
 
129
- }else{
129
+ echo "halloworld";
130
130
 
131
- echo"halloworld";
131
+
132
132
 
133
-
134
-
135
-
133
+
136
134
 
137
135
  }
138
136
 

1

訂正

2019/12/04 09:18

投稿

TeamPassionall
TeamPassionall

スコア80

test CHANGED
File without changes
test CHANGED
@@ -86,7 +86,7 @@
86
86
 
87
87
 
88
88
 
89
- file_put_contents("./pass/".$post['user'].".txt", $_post['pass']);
89
+ file_put_contents("./pass/".$_post['user'].".txt", $_post['pass']);
90
90
 
91
91
 
92
92