403 Forbidden error

Hi i need to send my to web host and im getting error 403 forbidden error but i from the and its a public web host.

#include <ESP8266WiFi.h>
#include <DHT.h>

const char* ssid     = "AdiWifi";
const char* password = "adithya123";

const char* host = "192.168.43.219";
#define DHTPIN 0
DHT dht(DHTPIN, DHT11);

#define LED D5 // Led in NodeMCU at pin GPIO16 (D0).

//float temp = 23;
//float humidity = 34;  
void setup() {

 Serial.begin(9600);
 delay(10);

 Serial.println();
 Serial.println();
 Serial.print("Connecting...");
 Serial.println(ssid);

 WiFi.begin(ssid, password);

 while(WiFi.status() !=WL_CONNECTED)
 {
    delay(500);
    Serial.print(".");
     
 }

 Serial.println("");
 Serial.println("WiFi Connected");
 Serial.println("IP Address :");
 Serial.println(WiFi.localIP());


}
 
void loop() {

  float h = dht.readHumidity();
  float t = dht.readTemperature();
 if(h>60)
 {
   digitalWrite(LED, LOW); 
 }
  //=================================
     //temp = temp + 2;
     //humidity +=  2; 
  //=================================
 Serial.print("Connecting to");
 Serial.println(host);

 WiFiClient client;

 const int httpPort = 8080;
 if(!client.connect(host, httpPort)){
     Serial.println("connection Failed");
     return;  
  }
   //Creating URI
  String url = "http://198.54.116.102/Nodemcu/save.php?";
         url += "temp=";
         url += t;
         url += "&humidity=";
         url += h;

  Serial.print("Requesting URL :");
  Serial.println(url);

 //This will send the request to the server and print them
  client.print(String("GET /") + url + " HTTP/1.1\r\n" + 
                "HOST:  " + host + "\r\n" +
              // "Accept: *" + "/" + "*\r\n" +
              // "Content-Length: " + temp.length() + humidity.length() +"\r\n" +
               "Content-Type: aplication/x-www-form-urlencoded\r\n" + 
               "Connection: close \r\n\r\n");

  unsigned long timeout =millis();             
  while(client.available() == 0){
     if(millis() - timeout > 5000){
      Serial.println(">>>Client Timeout");
      client.stop();
      return;
      }
  }

  while(client.available()){
     String line = client.readStringUntil('\r');
     Serial.print(line);
  }
  Serial.println();
  Serial.println("Closing Connection");

 delay(10000);
}

This is the arduino code.

<?php
 
    $temp     =(float) $_GET['temp'];
    $humidity = (float)$_GET['humidity'];
  

$servername = "localhost";
$username = "kaluthar";
$password = "*****";
$dbname = "temperature_humidity";

try {
    $conn = new PDO("mysql:host=$servername;dbname=$dbname", $username, $password);
    // set the PDO error mode to exception
    $conn->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
    $sql = "INSERT INTO temps (temp, humidity)
    VALUES ('".$temp."', '".$humidity."')";
    // use exec() because no results are returned
    $conn->exec($sql);
    echo "New record created successfully";
    }
catch(PDOException $e)
    {
    echo $sql . "
" . $e->getMessage();
    }

$conn = null;

?>

this is my php code. i have no idea why its getting me 403 error.

this is my serial monitor

Connecting to192.168.43.219
Requesting URL :http://198.54.116.102/Nodemcu/save.php?temp=28.80&humidity=63.00
HTTP/1.1 403 Forbidden
Date: Wed, 10 Apr 2019 05:40:12 GMT
Server: Apache/2.4.38 (Win64) OpenSSL/1.1.1b PHP/7.3.3
Vary: accept-language,accept-charset
Accept-Ranges: bytes
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=utf-8
Content-Language: en

cb
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="
e
en" xml:lang="
15
en">
<head>
<title>
39
Access forbidden!</title>
<link rev="made" href="mailto:
117
postmaster@localhost" />
<style type="text/css"><!--/*--><![CDATA[/*><!--*/ 
    body { color: #000000; background-color: #FFFFFF; }
    a:link { color: #0000CC; }
    p, address {margin-left: 3em;}
    span {font-size: smaller;}
/*]]>*/--></style>
</head>

<body>
<h1>
1d
Access forbidden!</h1>
<p>

6


  
87


    You don't have permission to access the requested object.
    It is either read-protected or not readable by the server.

  
4



b
</p>
<p>

49
If you think this is a server error, please contact
the <a href="mailto:
26
postmaster@localhost">webmaster</a>.

14

</p>

<h2>Error 
23
403</h2>
<address>
  <a href="/">
22
192.168.43.219</a>

  <span>
55
Apache/2.4.38 (Win64) OpenSSL/1.1.1b PHP/7.3.3</span>
</address>
</body>
</html>

And what is the output if you try to access http://192.168.43.219:8080 from your pc?

In your 'GET' header, you supply the entire URL.
Try sending only the part after protocol://host[:port]

So not this:

GET http://198.54.116.102/Nodemcu/save.php?temp=28.80&humidity=63.00 HTTP/1.1

but this:

GET /Nodemcu/save.php?temp=28.80&humidity=63.00 HTTP/1.1

septillion:
And what is the output if you try to access http://192.168.43.219:8080 from your pc?

Thats my wifis ip..

Do not include the host, protocol, or port in the URL you request - you have already specified that when you opened the connection to that host on that port.

Including the host, protocol, and port in the URL is technically legal, but it is never done in practice, and many servers don't handle it properly. Heck, in my day job I ran into a bug that had been undiscovered for years until a customer's badly written script made a request including those, and found the issue.

BUT - in your case, what you're requesting isn't even legal, because further down your code appends "GET /" to the front of it, so you're doing something like:

GET /http://198.54.116.102/Nodemcu/save.php?temp=28.80&humidity=63.00

Which is just wrong (and the server is correctly refusing to serve the obviously invalid URL)

So you want something like:

  String url = "Nodemcu/save.php?";
         url += "temp=";
         url += t;
         url += "&humidity=";
         url += h;

(well, String is evil and you should avoid using it like the plague in Arduino land, particularly the way you're doing it there, repeatedly appending to a String is how you bring out the bugs - but that's not the problem here, and it's less of a problem on an ESP8266 because of how much ram it has in general. Real programmers use c strings (null terminated fixed length character arrays), at least when programming embedded devices - it's good for the soul)

DrAzzy:
Do not include the host, protocol, or port in the URL you request - you have already specified that when you opened the connection to that host on that port.

Including the host, protocol, and port in the URL is technically legal, but it is never done in practice, and many servers don't handle it properly. Heck, in my day job I ran into a bug that had been undiscovered for years until a customer's badly written script made a request including those, and found the issue.

BUT - in your case, what you're requesting isn't even legal, because further down your code appends "GET /" to the front of it, so you're doing something like:

GET /http://198.54.116.102/Nodemcu/save.php?temp=28.80&humidity=63.00

Which is just wrong (and the server is correctly refusing to serve the obviously invalid URL)

So you want something like:

  String url = "Nodemcu/save.php?";

url += "temp=";
        url += t;
        url += "&humidity=";
        url += h;




(well, String is evil and you should avoid using it like the plague in Arduino land, particularly the way you're doing it there, repeatedly appending to a String is how you bring out the bugs - but that's not the problem here, and it's less of a problem on an ESP8266 because of how much ram it has in general. Real programmers use c strings (null terminated fixed length character arrays), at least when programming embedded devices - it's good for the soul)

okay sir i will do like that thank you very much

If you react to the last post, don't use quote please. Even more, try to avoid quoting long posts.

Hi guys thanks for helping out i have changed my code this

#include <ESP8266WiFi.h>
#include <SimpleDHT.h>
#include <ESP8266HTTPClient.h>
//#include <ESP8266WiFi.h>
#include <DHT.h>

const char* ssid     = "AdiWifi";
const char* password = "adithya123";
const char* host = "192.168.43.219";
//const char* server ="server110.web-hosting.com";
String get_host ="http://androidbuzz.org";
#define DHTPIN D3
DHT dht(DHTPIN, DHT11);
byte temperat= 0;
byte humid   = 0;
 
void setup() {
  Serial.begin(115200);
  delay(20);
  
  Serial.println();
  Serial.println();
  Serial.print("Connecting...");
  Serial.println(ssid);
  int pinDHT11 = D3;
  SimpleDHT11 dht11;
  int err = SimpleDHTErrSuccess;
  if((err = dht11.read(pinDHT11, &temperat, &humid, NULL))!= SimpleDHTErrSuccess)
  {
    return; 
  }
 WiFi.begin(ssid, password);
  while(WiFi.status() !=WL_CONNECTED)
 {
    delay(2500);
    Serial.print(".");
     
 }
 Serial.println("");
 Serial.println("WiFi Connected");
 Serial.println("IP Address :");
 Serial.println(WiFi.localIP());
}
void loop() {
  float h = dht.readHumidity();
  float t = dht.readTemperature();
 Serial.print("Connecting to");
 Serial.println(host);
 WiFiClient client;
 const int httpPort = 8080;
 if(!client.connect(host, httpPort)){
     Serial.println("connection Failed");
     return;  
  }
  HTTPClient http;
  String url1=get_host+"/Nodemcu/save.php?temp="+String(t)+"&humidity="+String(h);
  Serial.println(url1);
  http.begin(url1);

  int httpCode = http.GET();

  if(httpCode > 0)
  {
     Serial.printf("[HTTP] GET...Code:%s\n", httpCode);
     if(httpCode == HTTP_CODE_OK)
     {
       String payload = http.getString();
       Serial.println(payload);
        
     }
      http.end();
  }
  unsigned long timeout =millis();             
  while(client.available() == 0){
     if(millis() - timeout > 5000){
      Serial.println(">>>Client Timeout");
      client.stop();
      return;
      }
  }
  while(client.available()){
     String line = client.readStringUntil('\r');
     Serial.print(line);
  }
  Serial.println();
  Serial.println("Closing Connection");

 delay(10000);
}

My code is working but um getting a exception(28)

this is my serial output.

Connecting...AdiWifi
scandone
scandone
state: 0 -> 2 (b0)
state: 2 -> 0 (2)
reconnect
scandone
state: 0 -> 2 (b0)
state: 2 -> 3 (0)
state: 3 -> 5 (10)
add 0
aid 4
cnt 

connected with AdiWifi, channel 11
dhcp client start...
ip:192.168.43.164,mask:255.255.255.0,gw:192.168.43.84
.
WiFi Connected
IP Address :
192.168.43.164
Connecting to192.168.43.219
http://androidbuzz.org/Nodemcu/save.php?temp=26.00&humidity=53.00
[HTTP-Client][begin] url: http://androidbuzz.org/Nodemcu/save.php?temp=26.00&humidity=53.00
[HTTP-Client][begin] host: androidbuzz.org port: 80 url: /Nodemcu/save.php?temp=26.00&humidity=53.00
[HTTP-Client] connected to androidbuzz.org:80
[HTTP-Client] sending request header
-----
GET /Nodemcu/save.php?temp=26.00&humidity=53.00 HTTP/1.1
Host: androidbuzz.org
User-Agent: ESP8266HTTPClient
Connection: close
Accept-Encoding: identity;q=1,chunked;q=0.1,*;q=0

-----
[HTTP-Client][handleHeaderResponse] RX: 'HTTP/1.1 200 OK'
[HTTP-Client][handleHeaderResponse] RX: 'Date: Thu, 11 Apr 2019 07:11:15 GMT'
[HTTP-Client][handleHeaderResponse] RX: 'Server: Apache'
[HTTP-Client][handleHeaderResponse] RX: 'X-Powered-By: PHP/5.6.40'
[HTTP-Client][handleHeaderResponse] RX: 'Cache-Control: max-age=3600'
[HTTP-Client][handleHeaderResponse] RX: 'Expires: Thu, 11 Apr 2019 08:11:15 GMT'
[HTTP-Client][handleHeaderResponse] RX: 'Vary: Accept-Encoding'
[HTTP-Client][handleHeaderResponse] RX: 'Transfer-Encoding: chunked'
[HTTP-Client][handleHeaderResponse] RX: 'Content-Type: text/html; charset=UTF-8'
[HTTP-Client][handleHeaderResponse] RX: 'Connection: close'
[HTTP-Client][handleHeaderResponse] RX: ''
[HTTP-Client][handleHeaderResponse] code: 200
[HTTP-Client][handleHeaderResponse] Transfer-Encoding: chunked
Fatal exception 28(LoadProhibitedCause):
epc1=0x4020aa5a, epc2=0x00000000, epc3=0x00000000, excvaddr=0x000000c8, depc=0x00000000

Exception (28):
epc1=0x4020aa5a epc2=0x00000000 epc3=0x00000000 excvaddr=0x000000c8 depc=0x00000000

>>>stack>>>

ctx: cont
sp: 3ffffae0 end: 3fffffc0 offset: 01a0
3ffffc80:  3ffffd80 000000c8 3ffffce0 40209039  
3ffffc90:  3ffffd9f 00000010 00000000 00000012  
3ffffca0:  3ffe8300 00000012 3ffffd80 4020d2a6  
3ffffcb0:  00000129 3ffe8600 3fffc200 00000022  
3ffffcc0:  40102b57 00080000 3fffc200 3ffe8614  
3ffffcd0:  00000000 3ffe8613 3ffffd80 4020d6b7  
3ffffce0:  00000000 ffffffff 00000000 00000000  
3ffffcf0:  3ffffd00 00000012 00302073 fffffffe  
3ffffd00:  40204637 00000008 3ffffed0 4020a9c8  
3ffffd10:  3ffffde0 3ffffdb0 00000008 40100600  
3ffffd20:  0000001c 000001e0 3ffee804 3ffee804  
3ffffd30:  00000010 00000000 00000000 0000003f  
3ffffd40:  3ffffeb0 3ffffe80 0000000c 3ffe8300  
3ffffd50:  0000001c 00000009 00000001 3ffee804  
3ffffd60:  00000010 00000000 0000001c 41d00000  
3ffffd70:  3ffee720 3ffe8300 00000040 4020a985  
3ffffd80:  3ffffe42 6e617254 0000002d ffff0208  
3ffffd90:  3ffffe30 0000003f 6b6e7568 00000000  
3ffffda0:  00000010 3ffffe00 3ffffe00 40205e1f  
3ffffdb0:  3ffee804 000001c3 000001c3 40100600  
3ffffdc0:  000000c8 3ffee720 3ffefc04 40100d58  
3ffffdd0:  00000000 3ffee720 3ffffe30 40205ddc  
3ffffde0:  3ffe88ce 3ffee720 3ffffed0 40205df8  
3ffffdf0:  00000000 00000008 3ffee720 4020a9c8  
3ffffe00:  3ffffeb0 3ffffe80 00000008 00000000  
3ffffe10:  00000000 00000000 00000000 00000000  
3ffffe20:  00000000 00000000 00000000 40205950  
3ffffe30:  5454485b 47205d50 2e2e5445 646f432e  
3ffffe40:  00003a65 00000000 00000000 00000000  
3ffffe50:  3ffe88d6 00000000 00000000 00000000  
3ffffe60:  00000000 00000000 3ffffed0 40204b2c  
3ffffe70:  3ffffeb0 3ffffe80 00000008 41d00000  
3ffffe80:  3ffee804 000001be 000000c8 000000c3  
3ffffe90:  3ffef7a0 ff000000 3ffefbdc 40100d58  
3ffffea0:  3ffe8600 3fffff78 3ffffe80 3ffffeb0  
3ffffeb0:  42540000 3fffff78 3ffee720 41d00000  
3ffffec0:  42540000 000000c8 3ffee720 40202ad0  
3ffffed0:  3ffefc44 3ffefbe4 3ffefbe4 3ffef6c4  
3ffffee0:  0000000f 0000000f 3f000050 3f001388  
3ffffef0:  3ffefa7c 0000002f 0000002b 3ffef704  
3fffff00:  0000000f 00000004 3ffefa0c 0000000f  
3fffff10:  00000000 3ffefa2c 0000001f 00000011  
3fffff20:  3ffefa5c 0000000f 00000000 00000000  
3fffff30:  00000000 000000c8 ffffffff 40205800  
3fffff40:  00000001 00000000 40207340 00000000  
3fffff50:  00001388 3ffee6ec 00000000 3ffef8bc  
3fffff60:  00000000 00000000 00000000 00000000  
3fffff70:  00000000 00000000 00000000 00000000  
3fffff80:  00000000 3ffefc64 0000004f 00000041  
3fffff90:  a42ba8c0 feefeffe feefeffe 3ffee788  
3fffffa0:  3fffdad0 00000000 3ffee758 402069fc  
3fffffb0:  feefeffe feefeffe 3ffe8514 40100db9  
<<<stack<<<

 ets Jan  8 2013,rst cause:2, boot mode:(3,6)

septillion:
If you react to the last post, don't use quote please. Even more, try to avoid quoting long posts.

Oh i am very sorry sir i will not do it again