Good day everyone!
I'm trying to load an external php file using jQuery and I'm getting an undefined index because clearly I'm using a GET method in my external php file.
Here is my code:
main file
<script>
$(function() {
  $('#loadClients').load('clientsTable.php');
});
</script>
<body>
<div id="loadClients"><!-- load here--></div>
</body>
clientsTable.php
<table class="searchTbl" >
  <thead>
    <tr>
      <th width="200">Account #</th>
      <th width="300">Customer Name</th>
      <th width="150">Balance</th>
      <th width="100">Action</th>
    </tr>
  </thead>
  <tbody>
    <?php
      require ("db.php");
      $add = $_GET['address'];
      if ($_GET['address']=="All") 
      {
      $gets = mysql_query("SELECT * FROM customers");
      }
      else
      {
      $gets = mysql_query("SELECT * FROM customers WHERE cusadd='$add'");
      }
      while($row = mysql_fetch_assoc($gets))
      {
      ?>
    <tr>
      <td> <?= $row['accno']; ?> </td>
      <td> <?= $row['name']; ?> </td>
      <!-- <td style="color:#f0356e; "> <?php //number_format($row['totbal']); ?> </td> -->
      <td style="color:#f0356e; "> <?= formatMoney($row['totbal'], true); ?> </td>
      <td> <a href="#" data-reveal-id="myModal" data-reveal-ajax="records.php?id=<?= $row['accno']; ?>" id="viewData-<?= $row['accno']; ?>"> View Data </a> </td>
    </tr>
    <?php } ?>
  </tbody>
</table>
In my main file, the sample url is localhost/accountsknc/main.php?address=All. The error/notice I'm getting is Notice: Undefined index: address because maybe it's an external file.
Is there a way to handle this so that the data of the clients will show up in my main file? Thank you in advance.
PS: I know that my code is vulnerable because mysql is getting deprecated but I'm only testing this locally and will use PDO when I will implement it already.
 
     
    