title: PHP script runs automatically on page load
body: <p>need a favor. I wanted to make the internal PHP script runs automatically on page load. I have problems related to passing the value of the Date and User input from the form to the internal PHP script. I have tried both <code>$_POST</code> and <code>$_GET</code>. Should I put the script in an external script? I dont really need codes, just tell me what should I look into. Thanks!<br>
     
      
      
      
      Entry Log/Edit
      
      
      </p>
  
  <pre><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"&gt;&lt;/script&gt;
  &lt;script type="text/javascript" type="text/javascript" src="js/simpledtpicker.js"&gt;&lt;/script&gt;
  &lt;/head&gt;
  
  &lt;body style="text-align:center;"&gt;
  &lt;div class="wrapper"&gt;
  &lt;?php include('includes/header.php')?&gt;
  &lt;h1 style="text-align:center;"&gt;Entry Log/Edit&lt;/h1&gt;
  &lt;span&gt;
  &lt;form action="#" method="GET"&gt;
  &lt;table style="width:100%;"&gt;
  &lt;tr&gt;
      &lt;th style="text-align:left;"&gt;
      Entries for: 
      &lt;input type="text" name="dateOfEntry" class="dateOfEntry"&gt;
      &lt;script type="text/javascript"&gt;
              $(function()
              {
                  $('*[name=dateOfEntry]').appendDtpicker(
                  {
                      "dateOnly": true,
                      "dateFormat": "MM/DD/YYYY",
                      "autodateOnStart": true,
                      "closeOnSelected": true
                  });
              });
      &lt;/script&gt;         
      &lt;/th&gt;
      &lt;th style="text-align:right; padding-right: 0px;"&gt;
      User: 
      &lt;input type="text" name="user" value="Hrobi7198228" readonly="readonly" style="border:none; background-color:transparent"/&gt;
      &lt;/th&gt;
      &lt;th width="5px;"&gt;&lt;input type="submit" name="submit" value="Go"&gt;&lt;/th&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  &lt;/span&gt;
  &lt;br&gt;
  &lt;table class="entry" style="width: 100%;"&gt;
  &lt;thead&gt;
  
  &lt;?php 
  include ('connServer.php');
  
      $date = date('Y-m-d', strtotime(str_replace("-","/",$_GET['dateOfEntry'])));
      $username = $_GET['user'];
  
      $query = 'SELECT `ID`, `Date`, `Description`, `TypeOfDowntime`, `Machine#` FROM `machineissuesreport` WHERE `Date`="'.$date.'" AND `UpdatedBy` = "'.$username.'" ORDER BY `ID` DESC';
  
      $conn = mysqli_query($connection, $query);
  
      if ($conn)
      {
          echo '&lt;tr&gt;
                &lt;th width="5px"&gt;Edit&lt;/th&gt;
                &lt;th width="5px"&gt;Delete&lt;/th&gt;
                &lt;th&gt;Date&lt;/th&gt;
                &lt;th&gt;Details&lt;/th&gt;
                &lt;th width="100px" style="text-align:center;"&gt;Downtime Type&lt;/th&gt;
                &lt;th width="20px" style="text-align:center;"&gt;Machine No.&lt;/th&gt;
                &lt;/tr&gt;
                &lt;/thead&gt;
                &lt;tbody&gt;';
          while($row = mysqli_fetch_array($conn))
          {
              echo '&lt;tr&gt;';
              echo '&lt;td style="text-align: center" width="5px"&gt;&lt;a href="editMachineIssue.php?id='.$row["ID"].'" class="edit"&gt;Edit&lt;/a&gt;&lt;/td&gt;';
              echo '&lt;td style="text-align: center" width="5px"&gt;&lt;a href="#" id="'.$row['ID'].'" class="delete"&gt;Delete&lt;/a&gt;&lt;/td&gt;';
              echo '&lt;td style="display: none;"&gt;&lt;input type="hidden" value='.$row['ID'].'&gt;&lt;/td&gt;';
              echo '&lt;td width="5px" style="text-align: center; padding: 0px 5px;"&gt;'.$row['Date'].'&lt;/td&gt;';
              echo '&lt;td style="text-align: left; padding: 0px 0px 0px 12px;"&gt;'.$row['Description'].'&lt;/td&gt;';
              echo '&lt;td style="text-align: center;"&gt;'.$row['TypeOfDowntime'].'&lt;/td&gt;';
              echo '&lt;td style="text-align: center;"&gt;'.$row['Machine#'].'&lt;/td&gt;';
              echo '&lt;/tr&gt;';
          }
      }
  
  
  ?&gt;
  
  &lt;script type="text/javascript"&gt;
  $(document).ready(function() 
  {
      $.ajax
      ({
          type: 'POST', 
          data: {'run':run},
          success: function(data)
          {
          }
      });
  
      $('.delete').click(function()
      {
          if(confirm("Are you sure you want to delete this row?"))
          {
              var del_id = $(this).attr('id');
              var $ele = $(this).parent().parent();
  
              $.ajax({
                  type: 'POST',
                  url: 'machineEntryLogEdit.php',
                  data: {'del_id' : del_id},
                  success: function(data)
                  {
                      $ele.fadeOut().remove();            
                  },
                  error: function (xhr, status, error)
                  {
                      alert(this);
                  }
              });
          }
      });
  });
  &lt;/script&gt;
  &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I am still progressing on it, but please help me find the correct terms to Google. I am fairly new to PHP and AJAX.</p>