title: How do I make a default page for my website application with php?
body: <p>So I wish someone could give me a simple function or solution to put a default page on my site. That mean if the user try to access another page of my site he can't. He need to pass by this default page. Because in my site I have an admin page and I don't want a simple user to access it . I did some research on internet and I didn't find a good answer to my problem. Is there any way to do it simply by code and not changing the index file? To be more specific I want it to work only for one of my website and not for all . I have a login system for admin but since you can access the admin page directly by typing the address and not using  the login system it's a problem. I did try to do an index but the problem is when I try to log in then it redirect me on the default page and not on the admin page. I will appreciate any help. Best Regards a young programmer. </p>
  
  <p>Here is the index.php</p>
  
  <pre><code>&lt;?php
  
  header('Location: Foredeckmain.php');
  exit;
  ?&gt;
  </code></pre>
  
  <p>Here is the login page </p>
  
  <pre><code>&lt;?php
     ob_start();
     session_start();
  ?&gt; 
  
  &lt;html lang = "en"&gt;
  
     &lt;head&gt;
        &lt;title&gt;Foredeck Login.com&lt;/title&gt;
        &lt;link href = "css/bootstrap.min.css" rel = "stylesheet"&gt;
  
        &lt;style&gt;
           body {
              padding-top: 40px;
              padding-bottom: 40px;
              background-color: #6495ED;
           }
  
           .form-signin {
              max-width: 330px;
              padding: 15px;
              margin: 0 auto;
              color: #000000;
           }
  
           .form-signin .form-signin-heading,
           .form-signin .checkbox {
              margin-bottom: 10px;
           }
  
           .form-signin .checkbox {
              font-weight: normal;
           }
  
           .form-signin .form-control {
              position: relative;
              height: auto;
              -webkit-box-sizing: border-box;
              -moz-box-sizing: border-box;
              box-sizing: border-box;
              padding: 10px;
              font-size: 16px;
           }
  
           .form-signin .form-control:focus {
              z-index: 2;
           }
  
           .form-signin input[type="text"] {
              margin-bottom: 0 px;
              border-bottom-right-radius: 0;
              border-bottom-left-radius: 0;
              border-color:#000000;
           }
  
           .form-signin input[type="password"] {
              margin-bottom: 10px;
              border-top-left-radius: 0;
              border-top-right-radius: 0;
              border-color:#000000;
           }
  
           h3{
              text-align: ;
              color: #000000;
           }
           h1{
              text-align: ;
              color: #000000;
           }
        &lt;/style&gt;
  
     &lt;/head&gt;
  </code></pre>
  
  <p></p>
  
  <p></p>
  
  <pre><code>   &lt;?php
          $msg = '';
  
          if (isset($_POST['login']) &amp;&amp; !empty($_POST['username']) 
              &amp;&amp; !empty($_POST['password'])) {
  
              if ($_POST['username'] == 'foredeck' &amp;&amp; 
                $_POST['password'] == 'foredeck1') {
                $_SESSION['valid'] = true;
                $_SESSION['timeout'] = time();
                $_SESSION['username'] = 'foredeck';
                $msg ='Connexion Réussite';
                echo "&lt;script type='text/javascript'&gt;alert('Connexion Réussite');
                  window.location='foredeck.php'; &lt;/script&gt;";
  
                header("refresh:3 location: foredeck.php");
  
              }else {
                $msg='Identifiant ou Mot de Passe incorrecte';
                $msg =  "&lt;script type='text/javascript'&gt;alert('$msg')&lt;/script&gt;";
                 }
              }
       ?&gt;
    &lt;/div&gt; &lt;!-- /container --&gt;
  
    &lt;div class = "container"&gt;
  
       &lt;form class = "form-signin" role = "form" 
          action = "&lt;?php echo htmlspecialchars($_SERVER['PHP_SELF']); 
          ?&gt;" method = "post"&gt;
          &lt;h4 class = "form-signin-heading"&gt;&lt;?php echo $msg; ?&gt;&lt;/h4&gt;
          &lt;h1&gt;Foredeck@Admin&lt;/h1&gt; 
          &lt;h3&gt;Entrer l'identifant et le mot de passe:&lt;/h3&gt; 
          &lt;input type = "text" class = "form-control" 
                 name = "username" placeholder = "Identifiant " 
                 required autofocus&gt;&lt;/br&gt;
          &lt;input type = "password" class = "form-control"
                 name = "password" placeholder = "Mot de passe  " required&gt;
          &lt;br&gt;
  
          &lt;button class = "btn btn-lg btn-primary btn-block" type = "submit" 
                 name = "login"&gt;Se connecter&lt;/button&gt;
       &lt;/form&gt;
    &lt;/div&gt; 
    &lt;/body&gt;
  </code></pre>
  
  <p></p>
  
  <p>Here is the logout part </p>
  
  <pre><code>&lt;?php
     session_start();
     unset($_SESSION["username"]);
     unset($_SESSION["password"]);
  
     echo 'Déconnexion en cours...';
     header('Refresh: 2; URL = foredeckmain.php');
  ?&gt;
  </code></pre>