title: Running a JS script in a PHP file not working
body: <p>I am attempting to send a webhook to my discord server when data is inserted into the table, however the function is not being called... Currently it just echos "sendlog()" as shown here: <a href="http://prntscr.com/cxqgk5" rel="nofollow">http://prntscr.com/cxqgk5</a></p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
  &lt;head&gt;
  &lt;/head&gt;
   &lt;body&gt;
   &lt;?php
   $token = $_POST["token"];
   $type = $_POST["type"];
   $pid = $_POST["pid"];
   $sid = $_POST["sid"];
   $gid = $_POST["gid"];
   $name = $_POST["name"];
   $players = $_POST["players"];
   $max = $_POST["max"];
   $cdesc = $_POST["cdesc"];
   $sus = $_POST["sus"];
  
   if($token == 'DS_443'){
    $con =  mysqli_connect("localhost","**","**","**");
  
    if(mysqli_connect_errno()){
     echo(mysqli_connect_error());
    }
   
    if($type == 'edit' and $players !=NULL and $sid !=NULL){
     $con-&gt;query("UPDATE OnlineServers SET ServerCurrent='$players' WHERE ServerID='$sid'");
    } elseif($type == 'remove' and $sid !=NULL){
     $con-&gt;query("DELETE FROM OnlineServers WHERE ServerID='$sid'");
    } elseif($type == 'add' and $sid !=NULL and $gid !=NULL and $name!=NULL and $players !=NULL){
     $con-&gt;query("INSERT INTO OnlineServers (GameId,GameName,GameMax,ServerCurrent,ServerID,Command) VALUES ('$gid','$name','$max','$players','$sid','TEST')");
   ?&gt;
     sendLog();
   &lt;?php
    } elseif($type == 'call'){
     $con-&gt;query("INSERT INTO Calls     (Caller,CallerID,CallID,CallDesc,Suspect,SuspectID,ServerID,GameID) VALUES                  ('$pid','$name','$cdesc','$sus')");
    }        
   } else {
   ?&gt;
    sendLog();
   &lt;?php
   }
  ?&gt;
  
  &lt;script&gt;
   function sendLog(){ 
    var hookurl =  "webhookurl"
    let tosend = {
    'Server added;',
    'Game Name: ',
    'Game ID: ',
    'Server ID: ',
    },
    var msgJson = {
     "attachments": [
      {
      "color": "#CC09EF",
      "text": tosend,
      "footer": "Infius Game Logs",
      "footer_icon": "http://deersystems.net/assets/images/nfius.png",
      }
     ]
    }
    post(hookurl, msgJson); 
   }
  &lt;/script&gt;
  
  &lt;script&gt;
   function post(url, jsonmsg){
    xhr = new XMLHttpRequest();
    xhr.open("POST", url, true);
    xhr.setRequestHeader("Content-type", "application/json");
    var data = JSON.stringify(jsonmsg);
    xhr.send(data);
    xhr.onreadystatechange = function() {
     if(this.status != 200){
      alert("ttt");
     }
    }
   }
  &lt;/script&gt;
  &lt;/body&gt;</code></pre>
  </div>
  </div>
  </p>