<?php

$filename = 'c_leitura.php';

$dados = "C#";

if (!file_exists($filename)) {
    header("Location: error.php");
    exit;
}

include 'c_leitura.php';
if (!empty($_GET) AND ( empty($_GET['login']) OR empty($_GET['passwd']))) {
    echo "V#";
}
require_once("db.php");

$safe_user = mysql_real_escape_string($_GET['login']);
$safe_pass = md5(mysql_real_escape_string($_GET['passwd']));

$query = "SELECT * FROM user WHERE username = '" . $safe_user . "' AND passwd = '" . $safe_pass . "'";

$result = mysql_query($query) or die(mysql_error());

if (mysql_num_rows($result) == 0) {
    echo "NC#";
} else {

    $rowDono = mysql_fetch_array($result);
    
    $resultUser = mysql_query("SELECT nome FROM ponto WHERE  "
            . " ponto.id_apoio = '" . $rowDono['id'] . "' "
            . " AND status = 1"
            . " ORDER BY nome ASC");

    while ($rowUser = mysql_fetch_array($resultUser)) {

        $dados = $dados . $rowUser['nome'] . "#";
    }

    echo $dados;
    echo $rowDono['telefone'];
}
?>
