How to link my esp8266 to my website in 000webhost pls any 1 hlp me

this is source code in my esp8266
#include <ESP8266HTTPClient.h>

#include <ESP8266WiFi.h>

const char* ssid = “vathsal”;
const char* pass = “1234567890”;
const char* server = “vathsalblog.000webhostapp.com/recieve.php”;

String data;
WiFiClient client;
void setup()
{

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

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


   WiFi.begin(ssid, pass);

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

}

void loop()
{

                     if (client.connect(server,80))  
                  {  
                    Serial.println("connected to server");
                      data = "hello";

                         client.print("POST /http://vathsalblog.000webhostapp.com/recieve.php HTTP/1.1\n");
                         client.print("Host:  files.000webhost.com");
                         client.print("User-Agent: esp8266/1.0");
                         client.print("connection: close");
                         client.print("Content-Type: application/x-www-form-urlencoded\n");
                         client.print("Content-Length: ");
                         client.print(data.length());                            
                         client.print(data);
                         Serial.print(data);
                    }
      client.stop();

      Serial.println("Waiting...");

delay(10000);
}

and in my reciever script in server

<?php $data1 = $_POST['data']; $conn = mysqli_connect("localhost", "xxxxxxxxxxxx", "xxxxxx", "xxxxxxxx"); $sql=("insert into test (test1,test2) values ('$data1','$data2')"); $query=mysqli_query($conn,$sql) ?>

@hexa @ckhawand @ayu thoughts?:blush:

Arduino? :slight_smile:

@Vathsal
First of all, i have no idea about the language your are sending the request. But, i can see that you are setting a username and password as well as, host as files.000webhost.com. are you trying to connect with ftp?

No i just need it 2 snd it to my reciever script at recieve.php

Yes partially but it can be said a separate platform in IOT

I just need to send it to my webpage pls help mebout

Hi There,
Are you using Arduino?
Check this out: https://learn.adafruit.com/esp8266-temperature-slash-humidity-webserver/code

Good bro tanks i knw nd i hav searched and reserched in lot of codes bt anyway its not connecting with my database what i mean is its not sending any data to my my sql database(php admin) thats what my problem

After uploading code to the node mcu its just printing waiting in the serial monitor and not sending any data to my my sql database while checking the code in ide there’s no error

$data2 is not set in your php code.

1 Like

Ss bro but i hav set $data1 nd left $data2 blank so it will upload as blank in my database

You didn’t even set $data2
For empty, use
$data2 = "";

Hmm k i will try it thn i see if same occurs i inform u

1 Like

Alright, update us when done :slight_smile:

now i have changed my script and uploaded and every things done till same occurs!
i hav included all my photos of my work pls refer it

Screenshot%20(17)|690x387


it is my php script code

Tried using $_POST['data'] instead of $_REQUEST['data']?

till same can u suggest me some thing else

Wait, you have no database?