posting sensor data to sql database using esp8266 with arduino mega

am stuck while setting up the arduino code to send sensor data from my arduino mega to mysql on xampp, i have set up the arduino mega on serial1 . am using a database on my localhost but i seem to get nowhere.
am a novice arduino programmer .
it would be of great help if someone showed me how to send data from arduino to sql via esp8266 .

here is my terrible code

//#include "SoftwareSerial.h"
#include "Arduino.h"

//connection info for WiFi router
String ssid = "don";
String password = "qwertyuiop";

//create SoftSerial object for communication with ESP8266
//Serial1.begin; // RX, TX

String data; //data for the POST request
String server = "192.168.137.1"; // www.example.com
String uri = "write_data.php"; //server side script to call

//reset the esp8266 module
void reset() {
  Serial1.println("AT+RST");
  delay(3000);

  if (Serial1.find("OK"))
    Serial.println("Module Reset");
}

//connect to your wifi network
void connectWifi() {
  String cmd = "AT+CWJAP=\"" + ssid + "\",\"" + password + "\"";
  Serial1.println(cmd);
  delay(4000);

  if (Serial1.find("OK")) {
    Serial.println("Connected!");
  }
  else {
    connectWifi();
    Serial.println("Cannot connect to wifi");
  }
}

void setup() {
  Serial1.begin(9600); //start Serial for ESP comms
  Serial.begin(9600); //start regular serial for PC -> Arduino comms

  reset(); //call the ESP reset function
  connectWifi(); //call the ESP connection function
}

void loop() {
  int sensorValue = analogRead(A1);
  float voltage = sensorValue * (5.0 / 1024.0);

  data = String("turbidity = ");
  data = data + voltage;

  httppost();
  delay(7000);
}

void httppost() {
  Serial1.println("AT+CIPSTART=\"TCP\",\"" + server + "\",80"); //start a TCP connection.

  if (Serial1.find("OK")) {
    Serial.println("TCP connection ready");
  }
  delay(1000);

  String postRequest = String("POST ");
  postRequest = postRequest + uri + " HTTP/1.1\r\n" +
  "Host: " + server + "\r\n" +
  "Accept: *" + "/" + "*\r\n" +
  "Content-Length: " + data.length() + "\r\n" +
  "Content-Type: application/x-www-form-urlencoded\r\n" +
  "\r\n" + data;

  Serial.println("Post Request text: "); //see what the fully built POST request looks like
  Serial.println(postRequest);

  String sendCmd = "AT+CIPSEND="; //determine the number of caracters to be sent.
  Serial1.print(sendCmd);
  Serial1.println(postRequest.length());
  delay(500);

  if(Serial1.find(">")) {
    Serial.println("Sending..");
    Serial1.print(postRequest);

    Serial.println("Data to send: ");
    Serial.println(data);
    Serial.print("Data length: ");
    Serial.println(data.length());
    Serial.print("Request length: ");
    Serial.println(postRequest.length());
    Serial.println("Request Sent:");
    Serial.println(postRequest);

    if( Serial1.find("SEND OK")) {
      Serial.println("Packet sent");
      while (Serial1.available()) {
        String tmpResp = Serial1.readString();
        Serial.println(tmpResp);
      }

      // close the connection
      Serial1.println("AT+CIPCLOSE");
    }
  }
}

here is my php file

<?php

    // Prepare variables for database connection
   
    $dbusername = "arduino";  // enter database username, I used "arduino" in step 2.2
    $dbpassword = "arduinotest";  // enter database password, I used "arduinotest" in step 2.2
    $server = "localhost"; // IMPORTANT: if you are using XAMPP enter "localhost", but if you have an online website enter its address, ie."www.yourwebsite.com"
    $database_name = "test";
    // Connect to your database

    $dbconnect = mysqli_connect($server, $dbusername, $dbpassword, $database_name) or die('Error connecting to MySQL server.');
            
    // Prepare the SQL statement

    $sql = "INSERT INTO test.sensor (value) VALUES ('".$_GET["value"]."')";    

    // Execute SQL statement

    mysqli_query($dbconnect,$sql)  or die('Error querying database.');
    
?>

if its possible send me your code with comments or outline a tutorial.
i’ve researched but am frustrated with information which cant work.