I am struggling to use ESP8266 client to log into my web server (which is running in a PC host in local network). The ESP must login in order to see weather it must activate the sensor connected to it or not. Users can change the state of sensor activation (on/off) by logging in their portal. Therefore the esp8266 must be always aware of that. The way that comes to my mind is that the ESP8266 must log in like other browser clients. First, it should enter the login page through the following code:
client.print(String("GET /public_html/login.php") + " HTTP/1.1\r\n" +
"Host: " + host + "\r\n" +
"Connection: close\r\n" +
"\r\n"
);
Then I should post the username and password to the server. Normal human users who log in through a browser log in through the form below:
<form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]); ?>" method="post">
<div class="form-group <?php echo (!empty($username_err)) ? 'has-error' : ''; ?>">
<label>username</label>
<input type="text" name="username" class="form-control" value="<?php echo $username; >">
</div>
<div class="form-group <?php echo (!empty($password_err)) ? 'has-error' : ''; ?>">
<label>password</label>
<input type="password" name="password" class="form-control">
</div>
<div class="form-group">
<input type="submit" class="btn btn-primary" value="Login">
</div>
</form>
How can I do the same thing implemented above in ESP8266?