Statistics: Posted by andreysnug — Sun Jun 17, 2018 7:46 am
Code:
void sendSQL(){
Serial1.println("AT+CIPSTART=1,\"TCP\",\"" + server + "\",80");
delay(200);
if( Serial1.find("OK")){
Serial.println("TCP connection ready");
delay(200);
String postRequest = "GET " + uri + "?location=" + "\'" + location + "\'" +
"&sun_influence=" + "\'" + sunInfluence + "\'" + "&module_name=" + "\'" + moduleName + "\'" + "
HTTP/1.1\r\nHost: " + server + "\r\n\r\n";
Serial1.println("AT+CIPSEND=1," + String(postRequest.length()));
Serial.println("AT+CIPSEND=1," + String(postRequest.length()));
delay(200);
if(Serial1.available()){
if(Serial1.find(">")) {
Serial.println("Sending..");
Serial.print(postRequest);
Serial1.print(postRequest);
delay(200);
if(Serial1.find("SEND OK")){
Serial.println("Packet sent");
Serial1.println("AT+CIPCLOSE=1");
delay(200);
}
else
Serial.println("Packet cannot be sent");
}
else
Serial.println("ERROR");
}
else
Serial.println("Nothing received");
}
else
Serial.println("TCP connection failed");
}
Code:
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "gestion_lux";
// Create connection
$conn = new mysqli($servername, $username,$password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$val1 = $_GET['location'];
$val2 = $_GET['sun_influence'];
$val3 = $_GET['module_name'];
$sql = "INSERT INTO room(location,sun_influence,module_name) VALUES ($val1,$val2,$val3);";
if ($conn->query($sql) === TRUE) {
echo "Room parameters Saved Successfully!";
} else {
echo "Error:" . $sql . "<br>" . $conn->error;
}
$conn->close();
?>
Statistics: Posted by LizardOnTheRoad — Wed Mar 28, 2018 10:38 pm