title: PHP - How can I get the name of a POST technique from one page to another?
body: <p>I'm posting a select option from one page to another, on my actual server code (PHP), I'm wanting to firstly, get the POST name, for example, $_POST['selection_value'] and secondly, check if it's equal to a value from the selection, like : if($_POST['selection_value'] == 'time') {} . (time is the value of a selection option). How would I go about doing this ?</p>
  
  <p>My code for the POST grab :</p>
  
  <p><strong><em>The markup</em></strong></p>
  
  <pre><code>&lt;div class="form-group" style="padding-left: 4%;"&gt;
  &lt;div class="form-group m-r-12"&gt;
      &lt;label class="col-sm-12 control-label";"&gt;Add User&lt;/label&gt;
  &lt;/div&gt;
  
  &lt;input type="text" name="username" id="username" placeholder="Username" class="form-control" required /&gt;
  &lt;input type="text" name="email" id="email" placeholder="Email" class="form-control" required /&gt;
  &lt;input type="text" name="cpukey" id="cpukey" placeholder="CPUKey" class="form-control" required /&gt;
  &lt;button onclick="addUser()" class="btn btn-success"&gt;&lt;i class="fa fa-user-plus"&gt;&lt;/i&gt; Add User&lt;/button&gt;
  
  &lt;select class="form-control" id="selection_value" name="selection_value"&gt;
      &lt;option value="account_credits"&gt;Account Credits&lt;/option&gt;
      &lt;option value="free_gifted_credits"&gt;Free Gifted Credits&lt;/option&gt;
      &lt;option value="time"&gt;Member Server Days&lt;/option&gt;
  &lt;/select&gt;
  
  &lt;input type="text" name="add_to_all_value" id="add_to_all_value" placeholder="Value to add to current" class="form-control" required /&gt;
  &lt;button id="button1" onclick="add_to_all()" class="btn btn-primary"&gt;&lt;i class="fa fa-user-plus"&gt;&lt;/i&gt; Add To All Users&lt;/button&gt;
  </code></pre>
  
  <p></p>
  
  <p><em>The AJAX</em></p>
  
  <pre><code>            function add_to_all() {
              myOutput = document.getElementById('add_user_result');
              var member_selection  = $('#selection_value :selected').text()
              var member_value      =  $('#add_to_all_value').val();
  
              if(member_selection != "" &amp; member_value != "") {
                  $.ajax ({
                      type: "POST",
                      url: 'includes/ajax_data_add_to_all.php',
                      data: { selection: member_selection, value: member_value },
                      success:function(response) {
                          $("#add_user_result").show();
                          $('#add_user_result').fadeOut(3000).html(response);
                          header('Location: admin_members.php'); 
                      },
                      error: function() {
                          $("#add_user_result").show();
                          $('#add_user_result').fadeOut(3000).html(response);
                          header('Location: admin_members.php');
                      }
                  });
              } else {
                  $("#add_user_result").show();
                  $('#add_user_result').fadeIn(3000).fadeOut(3000);
                  myOutput.innerHTML = "&lt;font style='color: red;'&gt;You must fill in all the blanks.&lt;/font&gt;";
              }
  
              return false;
          }
  </code></pre>
  
  <p>Now my code for the add time (server code) :</p>
  
  <pre><code>    function grab_all_time() {
  global $con;
      $usersTime   = "SELECT time FROM users";
      $result             = $con-&gt;query($usersTime) or die("Error");
          while ($row = mysqli_fetch_assoc($result)) {
              return $row['time'];
          }
  }
  
  $AllusersTime = grab_all_time();
  
  if(!empty($_POST) &amp;&amp; isset($_POST)) {
      $selection          = mysqli_real_escape_string($con, $_POST['selection']);
      $value              = mysqli_real_escape_string($con, $_POST['value']);
  
      $membersDate = new DateTime($AllusersTime);
      $membersDate-&gt;add(new DateInterval('P'.$value.'D'));
      $finishedDT = $membersDate-&gt;format('Y-m-d') . "\n";
  
      if($selection == 'Member Server Days') {
          $insert_query = mysqli_query($con, "UPDATE users SET '".$selection."' + '".$value."'");
          if($insert_query) {
              echo '&lt;font style="color: green;"&gt;Successfully Added to all users&lt;/font&gt;';
              echo '&lt;META HTTP-EQUIV="Refresh" CONTENT="3; URL=admin_members.php"&gt;';
          }
          else {
              echo '&lt;font style="color: red;"&gt;Failed to add to all users&lt;/font&gt;';
              echo '&lt;META HTTP-EQUIV="Refresh" CONTENT="3; URL=admin_members.php"&gt;';
          }
      } else {
          $insert_query = mysqli_query($con, "UPDATE users SET time = '".$finishedDT."'");
          if($insert_query) {
              echo '&lt;font style="color: green;"&gt;Successfully Added to all users&lt;/font&gt;';
              echo '&lt;META HTTP-EQUIV="Refresh" CONTENT="3; URL=admin_members.php"&gt;';
          }
          else {
              echo '&lt;font style="color: red;"&gt;Failed to add to all users&lt;/font&gt;';
              echo '&lt;META HTTP-EQUIV="Refresh" CONTENT="3; URL=admin_members.php"&gt;';
          }
      }
  </code></pre>