示例#1
0
/**
 * 登陆
 **/
function login()
{
    if (isset($_POST['username']) && isset($_POST['password']) && $_POST['username'] != "" && $_POST['password'] != "") {
        // 用户名密码都不为空
        $userName = $_POST['username'];
        $password = $_POST['password'];
        $conn = createConn();
        // 创建数据库连接
        $result = mysql_query("select * from user where user_id = '{$userName}' and password = '******'");
        $count = mysql_num_rows($result);
        if ($count == 1) {
            // 登录成功
            $userIdResult = mysql_fetch_array($result);
            $_SESSION['userId'] = $userName;
            $_SESSION['userName'] = $userIdResult['user_name'];
            echo "<script language='javascript'>";
            echo "window.location.href='../main.php';";
            echo "</script>";
        } else {
            // 登陆失败
            echo "<script language='javascript'>";
            echo "alert('用户名或密码错误!');";
            echo "window.location.href='../index.php';";
            echo "</script>";
        }
        mysql_close($conn);
    } else {
        // 用户名或密码为空
        echo "<script language='javascript'>";
        echo "alert('用户名、密码不能为空!');";
        echo "window.location.href='../index.php';";
        echo "</script>";
    }
}
示例#2
0
function begun_or_not($page)
{
    global $duration, $diff;
    $connection = createConn();
    $var = -1;
    $sql_query = "SELECT * FROM googlockstart_end where no='0'";
    $temp = mysql_query($sql_query, $connection);
    $result = mysql_fetch_array($temp);
    finish($connection);
    $curr_timestamp = time();
    $diff = $curr_timestamp - $result['start_timestamp'];
    $duration = $result['finish_timestamp'] - $result['start_timestamp'];
    if ($diff < 0) {
        $msg = "Game has not started yet";
        $var = 0;
    } else {
        if ($curr_timestamp > $result['finish_timestamp']) {
            $msg = "Game has finished";
            $var = 1;
        } else {
            $msg = "Game has Started!!";
        }
    }
    if ($page == 1) {
        if ($var == 0) {
            header("location: index.php");
        } else {
            if ($var == 1) {
                header("location: login.php");
            }
        }
    } else {
        return $msg;
    }
}
示例#3
0
function fetchRecord($sql, $namedParameters = array())
{
    $conn = createConn();
    //Prepare the sql and execute the statment
    $query = $conn->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
    $query->execute($namedParameters);
    //Retieve all the rows
    $record = $query->fetch(PDO::FETCH_ASSOC);
    $conn = NULL;
    return $record;
}
示例#4
0
function fetchAllRecords($sql)
{
    $conn = createConn();
    //Prepare the sql and execute the statment
    $query = $conn->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
    $query->execute();
    //Retieve all the rows
    $records = $query->fetchAll(PDO::FETCH_ASSOC);
    // fetch becuase only one record
    return $records;
    $conn = null;
}
示例#5
0
function geProductDescription($Id)
{
    $sql = "SELECT `productDescription` \n" . "FROM `oe_product`\n" . "WHERE productId = :currentId";
    $conn = createConn();
    //Prepare the sql and execute the statment
    $query = $conn->prepare($sql, array(PDO::ATTR_CURSOR => PDO::CURSOR_FWDONLY));
    $namedParameters = array();
    $namedParameters[':currentId'] = $Id;
    $query->execute($namedParameters);
    //Retieve the row
    $ProductDescription = $query->fetch(PDO::FETCH_ASSOC);
    // fetch becuase only one record
    echo $ProductDescription['productDescription'];
    $conn = null;
}
示例#6
0
文件: play.php 项目: Vidhan/iFestSite
<?php

session_start();
require_once "require/constants.php";
require_once "require/functions.php";
require_once "require/begun_or_not_scheme.php";
begun_or_not(1);
// define any other scheme in begun_or_not_scheme.php
$done = 0;
if (isset($_COOKIE["username"]) && isset($_SESSION['username']) && $_COOKIE["username"] == $_SESSION['username']) {
    $username = $_SESSION['username'];
    $password = $_SESSION['password'];
    $connection = createConn();
    $temp_usr = mysql_real_escape_string($username);
    $temp_pass = mysql_real_escape_string($password);
    $sql_query = "select completed from googlockusers where username='******' and password='******'";
    //lock
    put_lock($connection, "googlockusers", "read");
    $temp = mysql_query($sql_query, $connection) or die("ERROR QUERY");
    remove_lock($connection);
    //unlock
    $result = mysql_fetch_array($temp);
    $result['completed'] = $result['completed'] + 1;
    $no = $result['completed'];
    if ($result['completed'] > $no_of_questions) {
        //finished all the questions
        $done = 1;
    }
    $sql_query = "select question from googlockquestions where no='{$result['completed']}'";
    $temp = mysql_query($sql_query, $connection) or die("Error in query");
    $question = mysql_fetch_array($temp);
示例#7
0
文件: main.php 项目: yemx910501/oes
<?php 
session_start();
if (!isset($_SESSION['userName'])) {
    // 未登录
    echo "<script language='javascript'>";
    echo "window.location.href='index.php';";
    echo "</script>";
} else {
    // 已登录
    include_once 'app/common/commonFunc.php';
    $conn = createConn();
    $userId = $_SESSION['userId'];
    $menuRs = mysql_query("select distinct m.* from menu m \n\t\t\tjoin role_menu_relation rm on m.menu_id = rm.menu_id \n\t\t\tjoin user_role_relation ur on rm.role_id = ur.role_id \n\t\t\tjoin user u on u.user_id = ur.user_id \n\t\t\twhere u.user_id = '{$userId}'\n\t\t\torder by m.sort");
}
?>

<!--<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">-->
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<meta http-equiv="X-UA-Compatible" content="IE=8" />
<title>在线考试系统</title>
<link href="dwz/themes/azure/style.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="dwz/themes/css/core.css" rel="stylesheet" type="text/css" media="screen"/>
<link href="dwz/themes/css/print.css" rel="stylesheet" type="text/css" media="print"/>
<link href="dwz/uploadify/css/uploadify.css" rel="stylesheet" type="text/css" media="screen"/>
<!--[if IE]>
<link href="themes/css/ieHack.css" rel="stylesheet" type="text/css" media="screen"/>
<![endif]-->