我现在需要你帮助解决PHP问题。我目前正在学习这门新语言,我的主页面有一个小问题,这里是代码
<?php
session_start();
if ($_SESSION['username']=='admin'){
header('Location: main.php');
exit;
}
if ($_POST) {
if ($_POST['username']=='admin' && $_POST['password']=='monpass') {
$_SESSION['username'] = $_POST['username'];
header('Location: main.php');
exit;
} else {
$errMsg =
'<div style = "
border: solid 2px red;
background: pink;
color: red;
padding: 1em;
display: inline-block">
Nom d utilisateur ou mot de passe invalide.
</div>';
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Projet Reilly - Administration - Authentification</title>
</head>
<body>
<h1>Accès contrôlé</h1>
<?php echo('coucou'); ?>
<p>Veuillez vous authentifier ci-dessous</p>
<form method="POST">
<input name="username" placeholder="Nom d'utilisateur">
<input name="password" placeholder="Mot de passe" type="password">
<input type="submit">
</form>
</body>
</html>
当我尝试通过http://localhost:81/reilly/admin/访问它时,出现ERR_CONNECTION_RESET错误。以下是一次尝试的Apache错误日志
[Thu Jan 07 10:34:09.863591 2016] [mpm_winnt:notice] [pid 5368:tid 376] AH00428: Parent: child process 2428 exited with status 3221225477 -- Restarting.
[Thu Jan 07 10:34:10.272091 2016] [ssl:warn] [pid 5368:tid 376] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Thu Jan 07 10:34:10.299120 2016] [mpm_winnt:notice] [pid 5368:tid 376] AH00455: Apache/2.4.18 (Win32) OpenSSL/1.0.2e PHP/7.0.1 configured -- resuming normal operations
[Thu Jan 07 10:34:10.299120 2016] [mpm_winnt:notice] [pid 5368:tid 376] AH00456: Apache Lounge VC14 Server built: Dec 9 2015 10:17:39
[Thu Jan 07 10:34:10.299120 2016] [core:notice] [pid 5368:tid 376] AH00094: Command line: 'd:\\xampp\\apache\\bin\\httpd.exe -d D:/xampp/apache'
[Thu Jan 07 10:34:10.307615 2016] [mpm_winnt:notice] [pid 5368:tid 376] AH00418: Parent: Created child process 8884
[Thu Jan 07 10:34:10.754944 2016] [ssl:warn] [pid 8884:tid 384] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Thu Jan 07 10:34:10.874107 2016] [ssl:warn] [pid 8884:tid 384] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Thu Jan 07 10:34:10.902136 2016] [mpm_winnt:notice] [pid 8884:tid 384] AH00354: Child: Starting 150 worker threads.
[Thu Jan 07 10:34:11.545960 2016] [mpm_winnt:notice] [pid 5368:tid 376] AH00428: Parent: child process 8884 exited with status 3221225477 -- Restarting.
[Thu Jan 07 10:34:11.910898 2016] [ssl:warn] [pid 5368:tid 376] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Thu Jan 07 10:34:11.935411 2016] [mpm_winnt:notice] [pid 5368:tid 376] AH00455: Apache/2.4.18 (Win32) OpenSSL/1.0.2e PHP/7.0.1 configured -- resuming normal operations
[Thu Jan 07 10:34:11.935411 2016] [mpm_winnt:notice] [pid 5368:tid 376] AH00456: Apache Lounge VC14 Server built: Dec 9 2015 10:17:39
[Thu Jan 07 10:34:11.935411 2016] [core:notice] [pid 5368:tid 376] AH00094: Command line: 'd:\\xampp\\apache\\bin\\httpd.exe -d D:/xampp/apache'
[Thu Jan 07 10:34:11.942416 2016] [mpm_winnt:notice] [pid 5368:tid 376] AH00418: Parent: Created child process 2656
[Thu Jan 07 10:34:12.391542 2016] [ssl:warn] [pid 2656:tid 384] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Thu Jan 07 10:34:12.516543 2016] [ssl:warn] [pid 2656:tid 384] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Thu Jan 07 10:34:12.547777 2016] [mpm_winnt:notice] [pid 2656:tid 384] AH00354: Child: Starting 150 worker threads.
[Thu Jan 07 10:34:17.287234 2016] [mpm_winnt:notice] [pid 5368:tid 376] AH00428: Parent: child process 2656 exited with status 3221225477 -- Restarting.
[Thu Jan 07 10:34:17.659230 2016] [ssl:warn] [pid 5368:tid 376] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Thu Jan 07 10:34:17.684247 2016] [mpm_winnt:notice] [pid 5368:tid 376] AH00455: Apache/2.4.18 (Win32) OpenSSL/1.0.2e PHP/7.0.1 configured -- resuming normal operations
[Thu Jan 07 10:34:17.684247 2016] [mpm_winnt:notice] [pid 5368:tid 376] AH00456: Apache Lounge VC14 Server built: Dec 9 2015 10:17:39
[Thu Jan 07 10:34:17.684247 2016] [core:notice] [pid 5368:tid 376] AH00094: Command line: 'd:\\xampp\\apache\\bin\\httpd.exe -d D:/xampp/apache'
[Thu Jan 07 10:34:17.691263 2016] [mpm_winnt:notice] [pid 5368:tid 376] AH00418: Parent: Created child process 9296
[Thu Jan 07 10:34:18.142009 2016] [ssl:warn] [pid 9296:tid 384] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Thu Jan 07 10:34:18.267010 2016] [ssl:warn] [pid 9296:tid 384] AH01909: www.example.com:443:0 server certificate does NOT include an ID which matches the server name
[Thu Jan 07 10:34:18.298262 2016] [mpm_winnt:notice] [pid 9296:tid 384] AH00354: Child: Starting 150 worker threads.
我试图关闭我的防病毒软件,以管理员身份运行xampp,更改端口(80到81和443到444再返回)但没有任何作用。似乎session_start()函数存在问题,因为当我尝试对其进行评论时,我可以毫无问题地访问该页面。
编辑:我也试图创建一个&#34;会话&#34;我的网站根目录下的文件夹,但它既不起作用。