Esp8266 fail to upload values to hostinger database server response 301

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>

//Include Lib for Arduino to Nodemcu
#include <SoftwareSerial.h>
#include <ArduinoJson.h>

//D6 = Rx & D5 = Tx
SoftwareSerial nodemcu(D6, D5);
// Update HOST URL here
int led = D0;
int red_led = D1;
// int val = 1;
// int val2 = 99;

String sendval, sendval2, postData;

void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(led, OUTPUT);
pinMode(red_led, OUTPUT);

Serial.begin(9600);
nodemcu.begin(9600);
while (!Serial) continue;

WiFi.begin("", "");

int connectCounter = 0;
while(WiFi.status() != WL_CONNECTED && connectCounter < 300) // 1 minute timeout (300 * 200ms delay)
{
Serial.print("..");
digitalWrite(red_led, LOW);
digitalWrite(led, HIGH);
delay(200);
digitalWrite(led, LOW);
digitalWrite(red_led, HIGH);
delay(200);
connectCounter++;
}

if (WiFi.status() != WL_CONNECTED) {
digitalWrite(red_led, HIGH);
Serial.println();
Serial.println("NodeMCU couldn't connect to WiFi!");
}
else {
Serial.println();
Serial.println("NodeMCU is Connected!");
Serial.println(WiFi.localIP());
digitalWrite(led, HIGH);
}
Serial.print(WiFi.status());
}

void loop() {

// put your main code here, to run repeatedly:
if (WiFi.status() != WL_CONNECTED) {
    Serial.println("WiFi disconnected! Reconnecting...");
    WiFi.reconnect();
    int connectCounter = 0;
    while(WiFi.status() != WL_CONNECTED && connectCounter < 300) // 1 minute timeout (300 * 200ms delay)
  {
    Serial.print("..");
    digitalWrite(red_led, LOW);
    digitalWrite(led, HIGH);
    delay(200);
    digitalWrite(led, LOW);
    digitalWrite(red_led, HIGH);
    delay(200);
    connectCounter++;
  }

    if (WiFi.status() != WL_CONNECTED) {
      digitalWrite(red_led, HIGH);
      Serial.println();
      Serial.println("NodeMCU couldn't reconnect to WiFi!");
  }
    else {
      Serial.println();
      Serial.println("NodeMCU is reconnected to WiFi!");
      Serial.println(WiFi.localIP());
      digitalWrite(led, HIGH);
  }
  
}

if (nodemcu.available()) {
  StaticJsonDocument<1000> jsonBuffer;
  DeserializationError error = deserializeJson(jsonBuffer, nodemcu);

  if (error) {
    Serial.print("deserializeJson() failed: ");
    Serial.println(error.c_str());
    return;
  }

  JsonObject data = jsonBuffer.as<JsonObject>();
  Serial.println("JSON Object Recieved");
  Serial.print("Recieved Soil Moisture:  ");
  for(int i=1; i<=4; i++) {
    String sendval = "Sensor " + String(i);
    int value = data["Sensor" + String(i)];
    String sendval2 = String(value);
    String moisturecat = data["Sensor" + String(i)+"Read"];
    postData = "sendval=" + sendval + "&sendval2=" + sendval2 + "&moisturecat=" + moisturecat;
    
    HTTPClient http;    // http object of clas HTTPClient
    WiFiClient wclient; // wclient object of clas HTTPClient    


    // // Convert integer variables to string
    // sendval = "Sensor 1";  
    //      sendval2 = String(sensor1);  

    
    // postData = "sendval=" + sendval + "&sendval2=" + sendval2;

    // We can post values to PHP files as  example.com/dbwrite.php?name1=val1&name2=val2&name3=val3
    // Hence created variable postDAta and stored our variables in it in desired format
    // For more detials, refer:- https://www.tutorialspoint.com/php/php_get_post.htm

    // Update Host URL here:-  
      
    http.begin(wclient, "http:///try/dbwrite.php");    // Connect to host where MySQL databse is hosted
    
    http.addHeader("Content-Type", "application/x-www-form-urlencoded");            //Specify content-type header
   

    
    
    int httpCode = http.POST(postData);   // Send POST request to php file and store server response code in variable named httpCode
    Serial.println("Values are, sendval = " + sendval + " and sendval2 = "+sendval2 + "moisture category = " + moisturecat );
    Serial.println("Server Response: " + String(httpCode) + " - " + http.errorToString(httpCode).c_str());
    Serial.println(postData);
    // if connection eatablished then do this

    if (httpCode == 200) { 
      Serial.println("Values uploaded successfully."); 
      Serial.println(httpCode); 
      String webpage = http.getString();    // Get html webpage output and store it in a string
      Serial.println(webpage + "\n"); 
    }

    // if failed to connect then return and restart

    else { 
      Serial.println(httpCode); 
      Serial.println("Failed to upload values. \n"); 
      http.end(); 
      return; 
    }

    delay(3000); 
    digitalWrite(LED_BUILTIN, LOW);
    delay(3000);
    digitalWrite(LED_BUILTIN, HIGH);
  }
    delay(60000);
// put your other code here
}}

Welcome to the forum

Your other topic on the same subject deleted.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.

Please follow the advice given in the link below when posting code, in particular the section entitled 'Posting code and common code problems'

Use code tags (the < CODE/ > icon above the compose window) to make it easier to read and copy for examination

https://forum.arduino.cc/t/how-to-get-the-best-out-of-this-forum