0

I need you help on a PHP problem right now. I'm currently learning this new language, and I have a small problem with my main page, here is the code

<?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>

When I try to reach it via http://localhost:81/reilly/admin/, I get a ERR_CONNECTION_RESET error. Here are the Apache error logs for just one try

[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.

I've tried to turn off my anti-virus, to run xampp as an administrator, to change the ports (80 to 81 and 443 to 444 and back again) but nothing works. It seems that it's a problem with the session_start() function, because when I try to comment it, I can reach the page without any problem.

EDIT : I also tried to create a "sessions" folder at the root of my website, but it doesn't work neither.

Kahsius
  • 747
  • 2
  • 7
  • 18

0 Answers0