iwa-panda1

Manage Weather Data by International Weather Agency (Version 1)
Log | Files | Refs

commit fa5cd27719dbd1554c6b5e06dbe693a5e3e7c7c4
parent 037b8221e27a58c8e6312c1febced08cbc939a85
Author: Johs <[email protected]>
Date:   Sat, 25 Mar 2023 15:44:09 +0100

Dataverwerker met validator, kleine fix in form.html

Diffstat:
Mdatainserter.php | 36+++++++++++++++++++++++++-----------
Mform.html | 2+-
2 files changed, 26 insertions(+), 12 deletions(-)

diff --git a/datainserter.php b/datainserter.php @@ -4,6 +4,7 @@ $username = "friedel"; $password = "hailiwa"; $dbname = "wap2"; + // Create connection $conn = mysqli_connect($servername, $username, $password, $dbname); // Check connection @@ -11,17 +12,31 @@ if (!$conn) { die("Connection failed: " . mysqli_connect_error()); } -$sql = "SELECT * FROM weerdata"; -$result = mysqli_query($conn, $sql); - if ($_SERVER["REQUEST_METHOD"] == "POST") { + include 'datavalidator.php'; // collect value of input field - $vname = $_POST['voornaam']; - $aname = $_POST['achternaam']; - $email = $_POST['email']; - $password = $_POST['password']; - $permissions = $_POST['permissions']; -} + $station = $_POST['STN']; + $date = $_POST['DATE']; + $time = $_POST['TIME']; + $temperatuur = $_POST['TEMP']; + $dauwpunt = $_POST['DEWP']; + $luchtdrukzeeniveau = $_POST['SLP']; + $luchtdrukstationniveau = $_POST['STP']; + $zichtbaarheid = $_POST['VISIB']; + $windsnelheid = $_POST['WDSP']; + $neerslag = $_POST['PRCP']; + $sneeuwdiepte = $_POST['SNDP']; + $gebeurtenissen = $_POST['FRSHTT']; + $bewolking = $_POST['CLDC']; + $windrichting = $_POST['WNDDIR']; -$json_data = file_get_contents(''); -\ No newline at end of file + $valid = validate_temperature($station, $temperatuur, $conn); + if ($valid) { + $sql = "Insert into weerdata Values($station, conc($date, $time), 1, $gebeurtenissen, $temperatuur, $dauwpunt, $luchtdrukzeeniveau, $luchtdrukstationniveau, $zichtbaarheid, $windsnelheid, $neerslag, $sneeuwdiepte, $gebeurtenissen, $bewolking, $windrichting,)"; + } else { + $sql = "Insert into weerdata Values($station, conc($date, $time), 0, $gebeurtenissen, $temperatuur, $dauwpunt, $luchtdrukzeeniveau, $luchtdrukstationniveau, $zichtbaarheid, $windsnelheid, $neerslag, $sneeuwdiepte, $gebeurtenissen, $bewolking, $windrichting,)"; + } + + $result = mysqli_query($conn, $sql); +} diff --git a/form.html b/form.html @@ -18,7 +18,7 @@ <br> <p>Please select the user permissions:</p> <input type="radio" id="Admin" name="permissions" value="1"> - <label for="html">Admin</label><br> + <label for="Admin">Admin</label><br> <input type="radio" id="Administratief medewerker" name="permissions" value="2"> <label for="Administratief medewerker">Administratief medewerker</label><br> <input type="radio" id="Wetenschappelijk medewerker" name="permissions" value="3">