Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/227.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
学习PHP和使用session\u start()时出错\u连接\u重置_Php_Xampp - Fatal编程技术网

学习PHP和使用session\u start()时出错\u连接\u重置

学习PHP和使用session\u start()时出错\u连接\u重置,php,xampp,Php,Xampp,我现在需要你帮我解决一个PHP问题。我目前正在学习这门新语言,我的主页有一个小问题,下面是代码 <?php session_start(); if ($_SESSION['username']=='admin'){ header('Location: main.php'); exit; } if ($_POST) { if ($_POST['username']=='admin' && $_POST['password']=='mon

我现在需要你帮我解决一个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>
我曾试图关闭我的防病毒软件,以管理员身份运行xampp,更改端口(80到81,443到444,然后再次更改),但没有任何效果。session_start()函数似乎有问题,因为当我尝试对它进行注释时,我可以毫无问题地访问页面


编辑:我还尝试在我的网站根目录下创建一个“会话”文件夹,但它也不起作用。

尝试解决方案已经尝试了所有方法,但没有任何效果。我在另一个线程中发现了这一点。它对我有用
[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.