如何通过WiFi连接在PHP网页中发送数据?我无法使用GET
和POST
。
Arduino代码:
Serial.println("Starting connection to server . . .");
Adafruit_CC3000_Client client = cc3000.connectTCP(ipAddress, 80);
if(client.connected()){
client.println("POST /vsample.php HTTP/1.1");
client.println("Host: localhost");
client.println("Content-Type: Application/x-www-form-urlencoded");
client.println("Content-Length: 100");
client.println("");
client.println("Real power = ");
client.print(realPower);
Serial.println("POSTED!");
delay(10000);
Serial.println("Connected and Data Sent");
}
PHP代码:
<?php
if(isset($_POST['realPower'])){
echo $_POST['realPower'];
}
?>