title: INSERT and DELETE data from database by clicking a link/button with ID USING MYSQLI
body: <p>I'm trying to <code>INSERT</code> and at the same time <code>DELETE</code> data from database. Whenever I view the info of a member by his ID in the URL, there will be a buttom/link with his info to ACCEPT that member. And if the admin click the ACCEPT button/link, that member will no longer be in the table of <code>requests</code> (and that's where DELETE should be done), and at the same time his details or data will be inserted in another table called "members". But when I click ACCEPT, it only echos the javascript for the confirmation, and when I click "Yes", nothing is happening, it just leads me back to the pendingRequests.php. I will share my code on here.</p>
  
  <p>This is the <strong>link</strong> to be clicked to <strong>view</strong> the details of the member <strong>from</strong> the <strong>pendingRequests.php</strong></p>
  
  <pre><code>&lt;a href="/test/admin/view_request.php?view_id=&lt;?php echo $row['id']; ?&gt;" &gt;VIEW&lt;/a&gt; 
  </code></pre>
  
  <p>And this is where the data of the member will display: <strong>view_requests.php</strong></p>
  
  <pre><code>&lt;?php
      include ('dbcontroller.php');
      if(isset($_GET['view_id']))
      {
          $id=$_GET['view_id'];
          $sql = mysqli_query($conn, "SELECT * from requests where id='$id'");
          $row = mysqli_fetch_array($sql);
      ?&gt;  
  
      ID:     &lt;?php echo  $row['id']; ?&gt;
  
      &lt;div class=" col-md-9 col-lg-9 "&gt; 
          &lt;table class="table table-user-information"&gt;
              &lt;tbody&gt;
                  &lt;tr&gt;
                      &lt;td&gt;&lt;h4&gt;&lt;b&gt;Profile Info&lt;/b&gt;&lt;/h4&gt;&lt;/td&gt;
  
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Name:&lt;/td&gt;
                      &lt;td&gt;&lt;?php echo $row['firstname']; ?&gt; &lt;?php echo $row['MI']; ?&gt; &lt;?php echo $row['lastname']; ?&gt;&lt;/td&gt;
  
                  &lt;/tr&gt;
                  &lt;tr&gt;
                      &lt;td&gt;Email-address:&lt;/td&gt;
                      &lt;td&gt;&lt;?php echo $row['email']; ?&gt;&lt;/td&gt;
  
                  &lt;/tr&gt;
  &lt;tr&gt;
                  &lt;td&gt;Gender:&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $row['gender']; ?&gt;&lt;/td&gt;
  
              &lt;/tr&gt;
               &lt;tr&gt;
                  &lt;td&gt;Status:&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $row['status']; ?&gt;&lt;/td&gt;
  
              &lt;/tr&gt;   
              &lt;tr&gt;
                  &lt;td&gt;Date of Birth:&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $row['bday']; ?&gt;&lt;/td&gt;
  
              &lt;/tr&gt;
               &lt;tr&gt;
                  &lt;td&gt;Contact Number:&lt;/td&gt;
                  &lt;td&gt;&lt;?php echo $row['contactno']; ?&gt;&lt;/td&gt;
  
              &lt;/tr&gt;   
  
              &lt;tr&gt;
                  &lt;td&gt;&lt;a href="javascript:view_id(&lt;?php echo $row['id']; ?&gt;) "&gt;ACCEPT&lt;/a&gt;&lt;/td&gt;
                  &lt;td&gt;DECLINE&lt;/td&gt;
              &lt;/tr&gt;
  &lt;?php 
  }
  $conn-&gt;close();
  ?&gt;
  &lt;/tbody&gt;
      &lt;/table&gt;        
  
  &lt;/div&gt;
  &lt;script type="text/javascript"&gt;
      function view_id(id)
      {
        if(confirm('Are you sure you want to accept this member request? '))
        {
          window.location='acceptRequest.php?view_id=='+view_id;
  
        }
      }
  &lt;/script&gt;
  </code></pre>
  
  <p>This is the <strong>link/button</strong> code where the admin clicks "<strong>ACCEPT</strong>" and the data of that member who owns that ID from "requests" table will delete and the info of the member will be inserted in the "members" table.</p>
  
  <pre><code>&lt;a href="javascript:view_id(&lt;?php echo $row['id']; ?&gt;) "&gt;ACCEPT&lt;/a&gt;
  </code></pre>
  
  <p>And this is my <strong>acceptRequest.php</strong> code</p>
  
  <pre><code>&lt;?php
  include('dbcontroller.php');
  if(isset($_GET['view_id']))
  {
      $sql = "SELECT * FROM requests WHERE id=".$_GET['view_id'];
  
      $firstname = $row['firstname'];
      $MI = $row['MI'];       
      $lastname = $row['lastname'];  
      $gender = $row['gender'];
      $status = $row['status'];
      $maiden = $row['maiden'];
      $bday = $row['bday'];
      $contactno = $row['contactno'];
      $email = $row['email'];
  
      mysqli_query($conn, "INSERT INTO members(id,'$firstname','$MI','$lastname','$gender','$status','$bday','$contactno','$email')");
  
      mysqli_query($conn, "DELETE FROM requests WHERE id=".$_GET['view_id']);
      header("Location: pendingrequests.php");
  }
  ?&gt;
  </code></pre>