1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.
Dismiss Notice
Welcome to our Education website, plz like our page facebook to support us. Thank You and wish you good navigation

Le sessions en PHP - Authentification

abdelouafiOct 4, 2016

    1. abdelouafi

      abdelouafi Administrator Staff Member

      Messages:
      295
      Likes Received:
      9
      Trophy Points:
      18
      Joined
      Sep 13, 2016
      Page d'authentification:
      Code:
      <?php
          $nom=$_POST["nom"];
          $prenom=$_POST["prenom"];
          $telephone=$_POST["telephone"];
          $capval=$_POST["capval"];
          $captcha=$_POST["captcha"];
          $valider=$_POST["valider"];
      ?>
      <html>
          <head>
          </head>
          <body>
              <form method="post" action="index.php">
                  Nom <input type="text" name="nom" value="<?php echo $nom?>"> <font color="red"> <?php if(isset($valider)){if(empty($nom)) echo "Nom invalide";}?></font> <br>
                  Prénom <input type="text" name="prenom" value="<?php echo $prenom?>">  <font color="red"> <?php  if(isset($valider)){if(empty($prenom)) echo "Prénom invalide";}?></font><br>
                  Téléphone <input type="text" name="telephone" value="<?php echo $telephone?>">  <font color="red"> <?php  if(isset($valider)){if((empty($telephone))||(!is_numeric($telephone))) echo "Téléphone invalide";}?></font> <br>
                  <?php
                      $x=rand(0,9);
                      $y=rand(0,9);
                      $z=$x+$y;
                      echo "$x + $y = ?";
                  ?>
                  <input type="hidden" name="capval" value="<?php echo $z?>">
                  <input type="text" name="captcha"> <?php if(isset($valider)){if ($captcha!=$capval) echo "<font color='red'>Résultat incorrect. Essayez à nouveau!</font>";}?><br>
                  <input type="submit" name="valider" value="Valider">
              </form>
          </body>
      </html>

      Page ma_session.php :
      Code:
      <?php
          session_start();
          if($_SESSION["loginok"]!="ok")
          header("location:auth.php");
      ?>
      <html>
          <head>
              <style>
                  h1{
                      color:eek:range;
                      font-family: monospace;
                  }
                  a{
                      color:black;
                      font-weight:bold;
                      text-decoration:none;
                      font-family:monospace;
                  }
                  a:hover{
                      color:red;
                      font-weight:bold;
                      text-decoration:none;
                      font-family:monospace;
                  }
              </style>
          </head>
          <body>
              <div align="center">
                  <h1>Bienvenu sur votre pase perso!</h1>
                  <a href="deconnexion.php">Quitter</a>
              </div>
          </body>
      </html>
       

      Attached Files:

      Last edited: Dec 24, 2016
      Loading...

Share This Page

Share