Advertisement
Guest User

Untitled

a guest
Apr 10th, 2020
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 5.61 KB | None | 0 0
  1. <?php
  2.     include("../common/reconnect.php");
  3.     include("../common/functions.inc");
  4.     include("../common/db_connect_pdo.php");
  5.  
  6.     if(!HaveAccess(50))
  7.         echo "<script type='text/javascript'>document.location.replace('../menu.php');</script>";
  8.  
  9.  
  10.     if(isset($_POST['InputTarget']) && isset($_POST['InputPower']) && isset($_POST['InputType']) && isset($_POST['InputFinal']))
  11.     {
  12.         echo "good";
  13.         // if(empty($_POST['InputName']))
  14.         //  echo "<script type='text/javascript'>document.location.replace(addTarget.php');</script>";
  15.         // else
  16.         // {
  17.         //  $name = mysqli_real_escape_string($db, $_POST['InputName']);
  18.  
  19.         //  // Checking if target is already registered
  20.         //     $query = "SELECT COUNT(id) as total FROM cibles WHERE name = '".$name."' ";
  21.         //     $result = mysqli_query($db, $query);
  22.         //      $data = mysqli_fetch_assoc($result);
  23.         //  if( $data['total'] == 0) // If == 0, then can register
  24.         //  {
  25.         //      // Registering target
  26.         //      $query = "INSERT INTO cibles(name) VALUES('".$name."')";
  27.         //      $result = mysqli_query($db, $query);
  28.  
  29.         //      echo "<script type='text/javascript'>document.location.replace('../menu.php');</script>";
  30.         //  }
  31.         // }
  32.     }
  33.     else
  34.     {
  35.         echo "<p style='color:white;'>";
  36.         echo isset($_POST['InputTarget'])." * ".isset($_POST['InputPower'])." - ".isset($_POST['InputType'])." + ".isset($_POST['InputFinal']);
  37.         echo "<br>todo";
  38.         echo "</p>";
  39.     }
  40. ?>
  41. <!DOCTYPE html>
  42. <head>
  43.     <meta charset="UTF-8">
  44.     <link rel="stylesheet" href="../css/bootstrap.min.css">
  45.     <link rel="stylesheet" href="../css/custom.css">
  46.     <title>Add Informations</title>
  47.     <link rel="icon" href="pics/favicon.ico" type="image/x-icon">
  48. </head>
  49. <body class="fbi_background">
  50.     </br></br></br>
  51.     <div class="col-md-4 offset-md-4">
  52.         <form action="addInformations.php" method="post">
  53.             <!-- First step -->
  54.             <div class="form-group" id="firstStep">
  55.                 <label for="InputTarget">Choose a target</label>
  56.                 <select name="InputTarget" size="1" class="form-control" onchange="secondStep()" id="firstStepInput" required>
  57.                     <?php
  58.                         $reponse = $bddPDO->prepare('SELECT id, name FROM cibles');
  59.                         $reponse->execute();
  60.  
  61.                         while ($donnees = $reponse->fetch())
  62.                         {
  63.                             echo '<option>'.$donnees['name'].'</option>';
  64.                         }
  65.                     ?>
  66.                 </select>
  67.                 <small id="targetHelp" class="form-text text-muted">Choose a target</small>
  68.             </div>
  69.             <!-- Second step -->
  70.             <div class="form-group" id="secondStep">
  71.                 <label for="InputPower">Power needed to access this information</label>
  72.                 <input type="number" name="InputPower" class="form-control" placeholder="50" autocomplete="off" onchange="thirdStep()" id="secondStepInput" required>
  73.             </div>
  74.             <!-- Third step -->
  75.             <div class="form-group" id="thirdStep">
  76.                 <label for="InputType">Choose a type of information</label>
  77.                 <select name="InputType" size="1" class="form-control" onchange="fourthStep()" id="thirdStepInput" required>
  78.                     <?php
  79.                         $reponse = $bddPDO->prepare('SELECT id, libelle FROM type');
  80.                         $reponse->execute();
  81.  
  82.                         while ($donnees = $reponse->fetch())
  83.                         {
  84.                             echo '<option>'.$donnees['libelle'].'</option>';
  85.                         }
  86.                     ?>
  87.                 </select>
  88.                 <small id="typeHelp" class="form-text text-muted">Choose a type of information</small>
  89.             </div>
  90.  
  91.  
  92.             <!-- Fourth step -->
  93.             <div class="form-group" id="fourthStepText">
  94.                 <label for="InputFinal">Enter the information</label>
  95.                 <input type="text" name="InputFinal" class="form-control" placeholder="50" autocomplete="off"  onchange="lastStep()" id="fourthStepTextInput">
  96.                 <small id="finalHelp" class="form-text text-muted">Fill it with the information you wish</small>
  97.             </div>
  98.  
  99.             <div class="form-group" id="fourthStepImage">
  100.                 <label for="InputFinal">Choose an image/label>
  101.                 <input type="file" name="InputFinal" class="form-control" accept="image/png, image/jpeg, image/jpg" id="fourthStepImageInput">
  102.                 <small id="finalHelp" class="form-text text-muted">Choose the image you wish</small>
  103.             </div>
  104.  
  105.             <button type="submit" class="btn btn-primary" id="buttonValidate">Click to add Information</button>
  106.         </form>
  107.     </div>
  108.  
  109.  
  110.     <script type="text/javascript">
  111.         var secondStepDone = false;
  112.         var thirdStepDone = false;
  113.         document.getElementById('secondStep').style.display = "none";
  114.         document.getElementById('thirdStep').style.display = "none";
  115.         document.getElementById('fourthStepText').style.display = "none";
  116.         document.getElementById('fourthStepImage').style.display = "none";
  117.         document.getElementById('buttonValidate').style.display = "none";
  118.  
  119.         document.getElementById('fourthStepImageInput').addEventListener('load', lastStep, false);
  120.  
  121.         function secondStep(){
  122.             if(!secondStepDone){
  123.                 secondStepDone = true;
  124.                 //document.getElementById('firstStepInput').disabled = true;
  125.                 document.getElementById('secondStep').style.display = "block";
  126.             }
  127.         }
  128.  
  129.         function thirdStep(){
  130.             if(!thirdStepDone){
  131.                 thirdStepDone = true;
  132.                 //document.getElementById('secondStepInput').disabled = true;
  133.                 document.getElementById('thirdStep').style.display = "block";
  134.             }
  135.         }
  136.  
  137.         function fourthStep(){
  138.             document.getElementById('thirdStepInput').disabled = true;
  139.             if(document.getElementById('thirdStepInput').value == "Image") {
  140.                 document.getElementById('fourthStepImage').style.display = "block";
  141.             }
  142.             else {
  143.                 document.getElementById('fourthStepText').style.display = "block";
  144.             }
  145.             document.getElementById('buttonValidate').style.display = "block";
  146.         }
  147.     </script>
  148. </body>
  149. </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement