Simple CODE problem please help me guys :(

i made a simple temperature sensor device using an lcd and dht11 and offcourse arduino uno

please tell me why when i press the button and when it’s HIGH it show the error message please help me

#include <LiquidCrystal.h>

#include <SimpleDHT.h>

LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// for DHT11,
//      VCC: 5V or 3V
//      GND: GND
//      DATA: 2
int pinDHT11 = 8;
SimpleDHT11 dht11;
int buttonState = 0;
int buttonPin = 7;
void setup() {
  Serial.begin(115200);
  pinMode(buttonPin, INPUT);
  lcd.begin(16, 2); lcd.home(); lcd.print("Loading...");
  delay(2000); lcd.clear();
 
}

void loop() {
  // start working...
  // this is fir keyboard typing
if (Serial.available()) {
    // wait a bit for the entire message to arrive
    delay(100);
    // clear the screen
    lcd.clear();
    // read all the available characters
    while (Serial.available() > 0) {
      // display each character to the LCD
      lcd.write(Serial.read()); delay(100);
    } delay(3000);} 
    // keyboard typing finished 
    ////////////////////////
    else {
  Serial.println("=================================");
  Serial.println("Sample DHT11...");

  // read without samples.
  byte temperature = 0;
  byte humidity = 0;
  if (dht11.read(pinDHT11, &temperature, &humidity, NULL)) {
    lcd.begin(16, 2);  lcd.print("Error, Check it Plz");//put autoscroll
    Serial.print("Read DHT11 failed.");
    delay(1000); lcd.clear(); return; 
  }

  Serial.print("Sample OK:  " );
  Serial.print((int)temperature); Serial.print(" *C, ");
  Serial.print((int)humidity); Serial.println(" %");
  // read button state
buttonState = digitalRead(buttonPin);
// condition

if (buttonState == HIGH) {
  lcd.clear();
  lcd.setCursor(0, 0);
   lcd.print("Temperature = "); lcd.print(temperature );
} else {
 
   lcd.setCursor(0, 0);
  lcd.print("Humidity = "); lcd.print(humidity );

  
   lcd.setCursor(0, 1);
  lcd.print("Created By Ali");
  delay(1000);  } 
  
  } }

alialsaffar: please tell me why when i press the button and when it's HIGH it show the error message please help me

What error message?

If look through the code there is an error message that pops if there isn’t humidity & temperature reading it also pops when i press the button,

Have you tried the DHT11 with the example sketch that comes with the DHT library?

The code works fine without the if conditions but when i add the if condition it mess up

dht11.read(pinDHT11, &temperature, &humidity, NULL)Does this return true if a successful reading was taken ?

lcd.begin(16, 2);  lcd.print("Error, Check it Plz");//put autoscroll
    Serial.print("Read DHT11 failed.");
    delay(1000); lcd.clear(); return;

Can you please put one statement per line? This is incredibly hard to read.

alialsaffar: The code works fine without the if conditions but when i add the if condition it mess up

Which if condition? There are several.