Sending data to a web hosting database

I tried sending the rfid card data with Nodemcu to my web database, but this problem arose when sending. Can anyone tell me where the problem is?

à| üȤlìÉã¬l$øD:nÅüI am waiting for card...
Tap card key: 4E:66:C8:75
requesting URL: belajar-hosting.xyz/log.php?idcard=4E:66:C8:75HTTP/1.1 400 Bad Request
Date: Mon, 09 Mar 2020 14:32:49 GMT
Content-Type: text/html; charset=utf-8
Content-Length: 150
Connection: close
X-Frame-Options: SAMEORIGIN
X-XSS-Protection: 1; mode=block
X-Content-Type-Options: nosniff
Referrer-Policy: no-referrer-when-downgrade
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload

400 Bad Request

400 Bad Request


nginx

my code is:

#include <ESP8266WiFi.h>
#include <ESP8266HTTPClient.h>
WiFiClient client;
#include <SPI.h>
#include <MFRC522.h>
#define SS_PIN D4
#define RST_PIN D2

#define ERROR_PIN D0
#define SUCCESS_PIN D1
#define CONN_PIN D8

void baca_database();

MFRC522 rfid(SS_PIN, RST_PIN);
MFRC522::MIFARE_Key key;
String request_string;
const char* host = "belajar-hosting.xyz"; //
HTTPClient http;
void setup() {
// put your setup code here, to run once:
WiFi.disconnect();
WiFi.begin("Sendaris","12345678ab");
while ((!(WiFi.status() == WL_CONNECTED))){
delay(300);
}
Serial.begin(9600);
SPI.begin();
rfid.PCD_Init();
Serial.println("I am waiting for card...");
}

void toggleConnStat() {
if(WiFi.status() == WL_CONNECTED) {
digitalWrite(CONN_PIN, HIGH);
} else {
digitalWrite(CONN_PIN, LOW);
}
}

String strID,val, data;

void loop() {
// put your main code here, to run repeatedly:
while (client.available()>0){
delay(10);
char c = client.read();
data+=c;
}
if (data.length()>0){
Serial.println(data);
data="";
}

if (!rfid.PICC_IsNewCardPresent() || !rfid.PICC_ReadCardSerial())
return;
// Serial.print(F("PICC type: "));
MFRC522::PICC_Type piccType = rfid.PICC_GetType(rfid.uid.sak);
// Serial.println(rfid.PICC_GetTypeName(piccType));
// Check is the PICC of Classic MIFARE type
if (piccType != MFRC522::PICC_TYPE_MIFARE_MINI &&
piccType != MFRC522::PICC_TYPE_MIFARE_1K &&
piccType != MFRC522::PICC_TYPE_MIFARE_4K) {
Serial.println(F("Your tag is not of type MIFARE Classic."));
return;
}
//id kartu dan yang akan dikirim ke database
strID = "";
for (byte i = 0; i < 4; i++) {
strID +=
(rfid.uid.uidByte < 0x10 ? "0" : "") +
String(rfid.uid.uidByte*, HEX) +*
(i != 3 ? ":" : "");
}
strID.toUpperCase();
Serial.print("Tap card key: ");
Serial.println(strID);
val = "500"; // nilai kartu yang akan dikirim
// tambah_database();
baca_database();
delay(1000);
}
void tambah_database()
{
if (!client.connect(host,80)) {
Serial.println("Gagal Konek");
return;
}
request_string = "belajar-hosting.xyz/log.php?idcard=";
request_string += strID;
request_string += "&val=";
request_string += val;
Serial.print("requesting URL: ");
Serial.println(request_string);
client.print(String("GET ") + request_string + " HTTP/1.1\r\n" + "Host: " + host + "\r\n" + "Connection: closernrn");
unsigned long timeout = millis();
while (client.available() == 0) {
if (millis() - timeout > 5000) {
Serial.println(">>> Client Timeout !");
client.stop();
return;
}
}
}
void baca_database()
{
if (!client.connect(host,80)) {
Serial.println("Gagal Konek");
return;
}
request_string = "belajar-hosting.xyz/log.php?idcard=";
request_string += strID;
Serial.print("requesting URL: ");
Serial.print(request_string);
client.print(String("GET ") + request_string + " HTTP/1.1rn" + "Host: " + host + "rn" + "Connection: closernrn");
unsigned long timeout = millis();
while (client.available() == 0) {
if (millis() - timeout > 5000) {
Serial.println(">>> Client Timeout !");
client.stop();
return;
}
}
}

Please use code tags (the </> button) when posting code or long output logs - it makes it easier for people to read, and prevents the forum from mangling code (in particular, the forum sees indexing an array by a variable named i, as the start of an italic tag - but parens and punctuation can also get turned into smilies and such without code tags)...

That said, it looks like you're not URL-encoding the query string, that could be the issue. A colon is not a valid character in a URL - it needs to be URL encoded, and as far as I can tell, you're not doing that...

@fauzan12

Moved your topic to it's current location as it is more suitable.

Could you take a few moments to Learn How To Use The Forum.
Other general help and troubleshooting advice can be found here.
It will help you get the best out of the forum in the future.