#431240 MagicBirdBerlin, 30.03.2019, 14:18:42 |
http Fehler 302 (web.coding) |
Hallöchen Forum, #include <Arduino.h>
#include <ESP8266WiFi.h>
#include <ESP8266WiFiMulti.h>
#include <ESP8266HTTPClient.h>
#include <Wire.h>
#include <MFRC522.h>
#include <SPI.h>
#define RST_PIN 5 // RST-PIN for RC522 - RFID - SPI - Module GPIO15
#define SS_PIN 4 // SDA-PIN for RC522 - RFID - SPI - Module GPIO2
MFRC522 myCard(SS_PIN, RST_PIN); // Create MFRC522 instance
#define USE_SERIAL Serial
ESP8266WiFiMulti WiFiMulti;
void setup()
{
USE_SERIAL.begin(115200);
delay(3000);
//WiFi.mode(WIFI_STA);
WiFiMulti.addAP("IoT", "password88");
SPI.begin(); // SPI bus
myCard.PCD_Init(); // MFRC522
pinMode(15,OUTPUT);
USE_SERIAL.println("starting...");
Serial.println("connect WLAN...");
if (WiFiMulti.run() == WL_CONNECTED)
{
Serial.println("");
Serial.println("connect WLAN handshake.");
Serial.println("IP:");
Serial.println(WiFi.localIP());
}
}
void loop()
{
if ( ! myCard.PICC_IsNewCardPresent()) //Wenn eine neue Karte nicht gelesen wird, kehren Sie zum Anfang zurück
{
delay(250);
return;
}
if ( ! myCard.PICC_ReadCardSerial()) //Wählen Sie eine aus, wenn aktuell mehr als eine Karte verwendet wird (verhindert den Fehler).
{
delay(250);
return;
}
String contenthex= "";
for (byte i = 0; i < myCard.uid.size; i++)
{
contenthex.concat(String(myCard.uid.uidByte[i], HEX));
}
contenthex.toUpperCase();
myCard.PICC_HaltA(); //Kartenbezogene Verfahren
Serial.println("Code of card " + contenthex);
if((WiFiMulti.run() == WL_CONNECTED))
{
HTTPClient http;
USE_SERIAL.print("[HTTP] post "+contenthex+" on Host.\n");
contenthex.replace(" ", "");
String url;
url = String("http://192.168.5.90/smarthome/rfid/rfid.php?rfid="+contenthex);
http.begin(url); //HTTP
int httpCode = http.GET();
if(httpCode > 0)
{
USE_SERIAL.printf("[HTTP] GET... code: %d\n", httpCode);
}
else
{
USE_SERIAL.printf("[HTTP] GET... failed, error: %s\n", http.errorToString(httpCode).c_str());
}
http.end();
}
}
<?php
require_once '../include/config.include.php';
require_once '../include/date_time.include.php';
if($_GET['rfid'] == true)
{
$statement = $pdo->prepare("SELECT COUNT(*) AS anzahl FROM $rfidtbl WHERE rfid = ?");
$statement->execute(array($_GET['rfid']));
$row = $statement->fetch();
if ($row['anzahl'] >= '1')
{
/* Lese Datenbankzeile für vorhandenen RFID Code und führe Aktion extern aus */
$sql = "SELECT * FROM $rfidtbl WHERE rfid = '".$_GET['rfid']."'";
$wert = $pdo->query($sql)->fetch();
$wertaktion = $wert['aktion'];
header("Location: http://192.168.5.90/smarthome/$wertaktion");
}
else
{
/* Schreibe neuen RFID Code in die Datenbank */
$datumdmy = date("d.m.Y");
$zeithi = date("H:i");
$statement = $pdo->prepare("INSERT INTO $rfidtbl (rfid, datum, zeit, counter) VALUES
|
#431244 MudGuard![]() München, 30.03.2019, 22:11:28 @ MagicBird |
http Fehler 302 |
> Wenn ich die rfid.php?rfid=code im Browser ausführe laufen alle |