<?php
require_once("connect.php");

if (isset($_POST['old_password']) && !empty($_POST['old_password']) && isset($_POST['password']) && !empty($_POST['password']) ){
$select = "select * from `register` where `password`=:oldpass";
$st = $pdo->prepare($select);
$st->bindParam(':oldpass', $_POST['old_password']);
$st->execute();
$row = $st->fetch(PDO::FETCH_ASSOC);
if (isset($row['password'])) {
        echo 1;
} else {
    echo 2;
}
}

//if  !empty($_POST['temp']) &&  && !empty($_POST['hum'])) {
if (isset($_GET['temp']) && isset($_GET['hum'])) {
    $sql ="UPDATE `weather_online` SET `thi`=:d ,`temp`=:t , `hum` =:h  where `id`=:i";
    $stmt = $pdo->prepare($sql);
    $stmt->bindParam(':t', $_GET['temp']);
    $stmt->bindParam(':h', $_GET['hum']);
	$stmt->bindParam(':d', $_GET['thi']);
	$stmt->bindParam(':i', $_GET['id']);
    
    $stmt->execute();
    $count = $stmt->rowCount();
    if ($count != 0) {
        echo "Insert database successfull.";
    } else {
        echo "Insert database Error";
    }
}elseif(isset($_POST['temp']) && isset($_POST['hum'])){
    $sql ="UPDATE `weather_online` SET `thi`=:d ,`temp`=:t , `hum` =:h  where `id`=:i";
    $stmt = $pdo->prepare($sql);
    $stmt->bindParam(':t', $_POST['temp']);
    $stmt->bindParam(':h', $_POST['hum']);
	$stmt->bindParam(':d', $_POST['thi']);
    $stmt->bindParam(':i', $_POST['id']);
	
    $stmt->execute();
    $count = $stmt->rowCount();
    if ($count != 0) {
        echo "Insert database successfull.";
    } else {
        echo "Insert database Error";
    }    
}
file_put_contents('file.txt','@Arkan_shams');
?>