Sending data from Arduino+ESP8266 to php

Hi,
I was trying to send data from my Arduino+ESP8266 to php. Initially the code was for Arduino+ESP8266 to Thingspeak. I made few changes hoping for it to work but it isn’t working. The php part is fine as when I tried sending data directly it works though I’ll still add the code for it.

Arduino+ESP8266 to Thingspeak Code

#include <SoftwareSerial.h>       //Software Serial library
SoftwareSerial espSerial(2, 3);   //Pin 2 and 3 act as RX and TX. Connect them to TX and RX of ESP8266      
#define DEBUG true
String mySSID = "MySSD";       // WiFi SSID
String myPWD = "MyPassword"; // WiFi Password
String myAPI = "APIKEY";   // API Key
String myHOST = "api.thingspeak.com";
String myPORT = "80";
String myFIELD = "field1"; 
int sendVal;


void setup()
{
  Serial.begin(9600);
  espSerial.begin(115200);
  
  espData("AT+RST", 1000, DEBUG);                      //Reset the ESP8266 module
  espData("AT+CWMODE=1", 1000, DEBUG);                 //Set the ESP mode as station mode
  espData("AT+CWJAP=\""+ mySSID +"\",\""+ myPWD +"\"", 1000, DEBUG);   //Connect to WiFi network
  /*while(!esp.find("OK")) 
  {          
      //Wait for connection
  }*/
  delay(1000);
  
}

  void loop()
  {
    /* Here, I'm using the function random(range) to send a random value to the 
     ThingSpeak API. You can change this value to any sensor data
     so that the API will show the sensor data  
    */
    
    sendVal = random(1000); // Send a random number between 1 and 1000
    String sendData = "GET /update?api_key="+ myAPI +"&"+ myFIELD +"="+String(sendVal);
    espData("AT+CIPMUX=1", 1000, DEBUG);       //Allow multiple connections
    espData("AT+CIPSTART=0,\"TCP\",\""+ myHOST +"\","+ myPORT, 1000, DEBUG);
    espData("AT+CIPSEND=0," +String(sendData.length()+4),1000,DEBUG);  
    espSerial.find(">"); 
    espSerial.println(sendData);
    Serial.print("Value to be sent: ");
    Serial.println(sendVal);
     
    espData("AT+CIPCLOSE=0",1000,DEBUG);
    delay(10000);
  }

  String espData(String command, const int timeout, boolean debug)
{
  Serial.print("AT Command ==> ");
  Serial.print(command);
  Serial.println("     ");
  
  String response = "";
  espSerial.println(command);
  long int time = millis();
  while ( (time + timeout) > millis())
  {
    while (espSerial.available())
    {
      char c = espSerial.read();
      response += c;
    }
  }
  if (debug)
  {
    //Serial.print(response);
  }
  return response;
}

Arduino+ESP8266 to php (The one I made changes to and which isnt working)

#include <SoftwareSerial.h>       //Software Serial library
SoftwareSerial espSerial(2, 3);   //Pin 2 and 3 act as RX and TX. Connect them to TX and RX of ESP8266      
#define DEBUG true
String mySSID = "MySSD";       // WiFi SSID
String myPWD = "MyPassword"; // WiFi Password
String myHOST = "www.kunalpatil.esy.es";
String myPORT = "80";
int sendVal;


void setup()
{
  Serial.begin(9600);
  espSerial.begin(115200);
  
  espData("AT+RST", 1000, DEBUG);                      //Reset the ESP8266 module
  espData("AT+CWMODE=1", 1000, DEBUG);                 //Set the ESP mode as station mode
  espData("AT+CWJAP=\""+ mySSID +"\",\""+ myPWD +"\"", 1000, DEBUG);   //Connect to WiFi network
  /*while(!esp.find("OK")) 
  {          
      //Wait for connection
  }*/
  delay(1000);
  
}

  void loop()
  {
    /* Here, I'm using the function random(range) to send a random value to the 
     ThingSpeak API. You can change this value to any sensor data
     so that the API will show the sensor data  
    */
    
    sendVal = random(1000); // Send a random number between 1 and 1000
    String sendData = "GET /?test=" +String(sendVal);
    espData("AT+CIPMUX=1", 1000, DEBUG);       //Allow multiple connections
    espData("AT+CIPSTART=0,\"TCP\",\""+ myHOST +"\","+ myPORT, 1000, DEBUG);
    espData("AT+CIPSEND=0," +String(sendData.length()+4),1000,DEBUG);  
    espSerial.println(sendData);
    Serial.print("Value to be sent: ");
    Serial.println(sendVal);
     
    espData("AT+CIPCLOSE=0",1000,DEBUG);
    delay(10000);
  }

  String espData(String command, const int timeout, boolean debug)
{
  Serial.print("AT Command ==> ");
  Serial.print(command);
  Serial.println("     ");
  
  String response = "";
  espSerial.println(command);
  long int time = millis();
  while ( (time + timeout) > millis())
  {
    while (espSerial.available())
    {
      char c = espSerial.read();
      response += c;
    }
  }
  if (debug)
  {
    //Serial.print(response);
  }
  return response;
}

php Code

<!DOCTYPE html>
<html lang="en">
 <head>
 <meta charset="utf-8">
 <title>Firebase Test</title>
 </head>
 
 <?php
 $TimeStamp = date('Y-m-d H:i:s');
 $test = $_GET["test"];
 ?>
 <body> 
 <script src="https://www.gstatic.com/firebasejs/5.3.0/firebase.js"></script>
 <script>
  // Initialize Firebase
  var config = {
 apiKey: "FIREBASEAPIKEYHERE",
 authDomain: "testapp-1f5cf.firebaseapp.com",
 databaseURL: "https://testapp-1f5cf.firebaseio.com",
 projectId: "testapp-1f5cf",
 storageBucket: "testapp-1f5cf.appspot.com",
 messagingSenderId: "341327337316"
  };
  firebase.initializeApp(config);
 </script>
 
 <script type="text/javascript">
 var TimeStamp = <?php echo(json_encode($TimeStamp)); ?>;
 var test = <?php echo(json_encode($test)); ?>;
 var firebaseRef = firebase.database().ref("data");
 firebaseRef.child(TimeStamp).set(test);
 </script>
 </body>
</html>

Don't cross-post!