コード例 #1
0
function get_user_id($email)
{
    $dbh = get_database_handler();
    $query = "SELECT userid FROM utilizador WHERE email=? LIMIT 1;";
    $sth = $dbh->prepare($query);
    $sth->execute(array($email));
    if ($sth->rowCount()) {
        $row = $sth->fetch(PDO::FETCH_ASSOC);
        $dbh = null;
        return $row['userid'];
    }
    $dbh = null;
    return null;
}
コード例 #2
0
<?php

require_once 'appfunctions.php';
if (is_logged_in()) {
    show_header();
} else {
    redirect_to_login();
}
$remove_url = get_curr_dir() . "/remove.php?type=3&typecnt=";
?>


<?php 
if (isset($_REQUEST['typecnt'])) {
    $dbh = get_database_handler();
    $dbh->beginTransaction();
    $query = 'SELECT t.typecnt,c.typecnt,c.campocnt,c.nome FROM tipo_registo as t, campo as c
WHERE t.userid=c.userid AND c.userid=? AND c.ativo=1 AND t.ativo=1 AND t.typecnt=c.typecnt AND t.typecnt=?
GROUP BY c.nome;';
    $sth = $dbh->prepare($query);
    try {
        $sth->execute(array($_SESSION['userid'], $_REQUEST['typecnt']));
        echo "<h2>campos do registo {$_REQUEST['typecnt']}</h2>";
        echo "<table border=\"1\" cellspacing=\"5\">\n";
        echo "<tr>\n";
        echo "<th>campocnt</th>";
        echo "<th>nome</th>";
        echo "<th></th>";
        echo "</tr>\n";
        foreach ($sth as $row) {
            echo "<tr>\n";
コード例 #3
0
function handle_reg_type_removal()
{
    if (isset($_GET['id'])) {
        $id = $_GET['id'];
        $dbh = get_database_handler();
        try {
            $dbh->beginTransaction();
            $params = clone_reg_type($dbh, $id);
            update_reg_type_info($dbh, $params);
            $dbh->commit();
        } catch (PDOException $e) {
            echo '<p>ERROR: {' . $e->getMessage() . '}</p>';
        }
        $dbh = null;
    } else {
    }
    redirect_with_message(get_prev_url(), SUCCESS_MSG_REG_TYPE, REDIRECT_DELTA);
}