I'm updating this for the last time to say everything is great thank you all or help on my screw up's and I'm posting a final code on it all working. Hope this helps others as so many have helped me.
#include <ESP8266WiFi.h>
#include <DHT.h>
#include <SPI.h>
const char* ssid = "SSID";
const char* password = "SSID PASSWORD";
const char* host = "Your Server address here";
#define DHTPIN 2 // SENSOR PIN
#define DHTTYPE DHT22 // SENSOR TYPE - THE ADAFRUIT LIBRARY OFFERS SUPPORT FOR MORE MODELS
DHT dht(DHTPIN, DHTTYPE);
long previousMillis = 0;
unsigned long currentMillis = 0;
long interval = 1000; // READING INTERVAL
int t = 0; // TEMPERATURE VAR
int h = 0; // HUMIDITY VAR
String data;
void setup()
{
Serial.begin(9600);
Serial.println();
Serial.printf("Connecting to %s ", ssid);
WiFi.begin(ssid, password);
while (WiFi.status() != WL_CONNECTED)
{
delay(500);
Serial.print(".");
}
Serial.println(" connected");
dht.begin();
h = (int) dht.readHumidity();
t = (int) dht.readTemperature();
}
void loop()
{
currentMillis = millis();
if(currentMillis - previousMillis > interval) { // READ ONLY ONCE PER INTERVAL
previousMillis = currentMillis;
h = (int) dht.readHumidity();
t = (int) dht.readTemperature();
}
data = "temp1=";
data.concat(t);
data.concat("&hum1=");
data.concat(h);
Serial.print(t);
Serial.print("\n");
Serial.print(h);
Serial.print("\n");
WiFiClient client;
Serial.printf("\n[Connecting to %s ... ", host);
if (client.connect(host, 80))
{
Serial.println("connected]");
client.println("POST /add.php HTTP/1.1");
client.println("Host: repeat again your site server address here.");
client.println("Content-Type: application/x-www-form-urlencoded");
client.print("Content-Length: ");
client.println(data.length());
client.println();
client.print(data);
Serial.println(data);
Serial.println("\n[Disconnected]");
}
else
{
Serial.println("connection failed!]");
client.stop();
}
delay(5000);
}