Replies: 1 comment
-
sorry is this code <script src='https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js' integrity='sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM' crossorigin='anonymous'></script> <title>Envio de datos</title> "; require_once('Conexion.php'); $Dispositivo = $_POST['Dispositivo']; $Estado_Puerta = $_POST['Estado_Puerta']; $User = $_POST['User']; $Pass = $_POST['Pass']; $Conn = new Conexion(); $query = "UPDATE device_state SET Estado_Puerta = '$Estado_Puerta' WHERE Id_Device ='$Dispositivo'"; $Insert = mysqli_query($Conn->Conectar_DataBase(),$query); $query = "INSERT INTO device_historic (Id_Device, Estado_Puerta, Hora) VALUES ('$Dispositivo', '$Estado_Puerta', NOW())"; $Insert = mysqli_query($Conn->Conectar_DataBase(),$query); if(strcmp($User, 'Tatis123') === 0 && strcmp($Pass, 'Mona28102000') === 0){ echo "
Has ingresado correctamente
";
echo ""; $query = "SELECT * FROM device_state WHERE Id_Device = 'Tarjeta_1'"; $Select = mysqli_query($Conn->Conectar_DataBase(),$query); while($row = mysqli_fetch_array($Select)) { /*Imprimir campo por indice*/ //echo $row[0]; /*Imprimir campo por nombre*/ echo " "; echo "El estado de la puerta actual es: ". $row['Estado_Puerta']; echo ""; } echo ""; echo "Ver Historico"; }else{ echo " ";
echo "Verifica tus datos";
echo " ";
echo "Volver";
}
?>
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hello, I am having problems in carrying out my project, I only want to monitor the opening of a door through a web page, I am using a free hosting infinityfree, when I use the post method so that my arduino sends data to php the message appears next error
<script type="text/javascript" src="/aes.js" ></script><script>function toNumbers(d){var e=[];d.replace(/(. .)/g,function(d){e.push(parseInt(d,16))});return e}function toHex(){for(var d=[],d=1==arguments.length&&arguments[0 ].constructor==Array?arguments[0]:arguments,e="",f=0;fd[f]?"0":"")+d [f].toString(16);return e.toLowerCase()}var a=toNumbers("f655ba9d09a112d4968c63579db590b4"),b=toNumbers("98344c2eee86c3994890592585b49f80"),c=toNumbers("8f058666546f07210d33ae9db37dbc97");document.cookie="__test ="+toHex(slowAES.decrypt(c,2,a,b))+"; expires=Thu, 31-Dec-37 23:55:55 GMT; path=/"; location.href="http://monitoreopuerta.42web.io/Prueba_Recibe.php?i=1";</script>This site requires Javascript to work, please enable Javascript in your browser or use a browser with Javascript supportI don't know how to solve it, I leave my arduino code and my php codes
#include<ESP8266WiFi.h>
#include<WiFiClient.h>
#include<ESP8266HTTPClient.h>
boolean Estado = true;
String Estado_Puerta = "";
String URL = "http://monitoreopuerta.42web.io/Prueba_Recibe.php";
WiFiClient Client; // Creacion del objeto Cliente
HTTPClient http; // Creacion del objeto HTTP
void setup() {
// put your setup code here, to run once:
pinMode(16,INPUT); //Inicializacion
pinMode(5,OUTPUT);
Serial.begin(115200);
WiFi.begin(ssid,Password);
while(WiFi.status() != WL_CONNECTED){
delay(500);
Serial.println("");
}
Serial.println("/////////////////////////////////////////////////////////////////////////////");
Serial.print("Conectado a la red: ");
Serial.println(WiFi.SSID());
Serial.print("ip; ");
Serial.println(WiFi.localIP());
Serial.println("/////////////////////////////////////////////////////////////////////////////");
//server.begin();
}
void loop() {
if(digitalRead(16) == 1){ // Codigo de apertura de la puerta
http.begin(Client, URL);
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
String PostData = "Dispositivo=Tarjeta_1 &Estado_Puerta="+ Estado_Puerta;
int httpCode = http.POST(PostData);
String payload = http.getString();
Serial.println(httpCode);
Serial.println(payload);
delay(1000);
http.end();
}else if(digitalRead(16) == 0){
digitalWrite(5,1);
Estado_Puerta = "Abierta";
Estado = false;
http.begin(Client, URL);
http.addHeader("Content-Type", "application/x-www-form-urlencoded");
String PostData = "Dispositivo=Tarjeta_1 &Estado_Puerta="+ Estado_Puerta;
int httpCode = http.POST(PostData);
String payload = http.getString();
Serial.println(httpCode);
Serial.println(payload);
delay(1000);
http.end();
}
php code
<script src='https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js' integrity='sha384-MrcW6ZMFYlzcLA8Nl+NtUVF0sA7MsXsP1UyJoMp4YLEuNSfAP+JcXn/tWtIaxVXM' crossorigin='anonymous'></script> <title>Envio de datos</title> "; require_once('Conexion.php'); $Dispositivo = $_POST['Dispositivo']; $Estado_Puerta = $_POST['Estado_Puerta']; $Conn = new Conexion(); $query = "UPDATE device_state SET Estado_Puerta = '$Estado_Puerta' WHERE Id_Device ='$Dispositivo'"; $Insert = mysqli_query($Conn->Conectar_DataBase(),$query); $query = "INSERT INTO device_historic (Id_Device, Estado_Puerta, Hora) VALUES ('$Dispositivo', '$Estado_Puerta', NOW())"; $Insert = mysqli_query($Conn->Conectar_DataBase(),$query); $query = "SELECT * FROM device_state WHERE Id_Device = 'Tarjeta_1'"; $Select = mysqli_query($Conn->Conectar_DataBase(),$query); while($row = mysqli_fetch_array($Select)) { /*Imprimir campo por indice*/ //echo $row[0]; /*Imprimir campo por nombre*/ echo ""; echo "El estado de la puerta actual es: ". $row['Estado_Puerta']; echo "
"; } $query = "SELECT * FROM device_historic"; $Select = mysqli_query($Conn->Conectar_DataBase(),$query); echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; while ($row = mysqli_fetch_array($Select)){ echo "Beta Was this translation helpful? Give feedback.
All reactions