示例#1
0
                    $result2 = $db->query($sql2)->fetch();
                    if ($result2[0] == 0) {
                        //if user wants to go to land of unicorns
                        if ($password == "takemetothelandofunicorns") {
                            print '
	    <div style="position:absolute;z-index:0;left:0;top:0;width:100%;height:100%">
  	     <img src="img/rainbow.gif" style="width:100%;height:100%" alt="[]" />
	    </div>
            <script src="js/unicorn.js"></script>
            <style> body, a, a:hover { cursor:url(http://www.dolliehost.com/dolliecrave/cursors/cursors-all/animals01.gif), auto }
	    </style>
           ';
                            try_again("Welcome...to the land of unicorns...", $username);
                        } else {
                            //you were just plain wrong.
                            try_again("Username/password pair not found.", $username);
                        }
                    } else {
                        //you are logging in for the first time. We'll bring you to the signup page.
                        $_SESSION['ta_id'] = $password;
                        $sql3 = "select name_first, name_last, department from ta where sid = '{$password}';";
                        $result3 = $db->query($sql3)->fetch();
                        $name = $result3['name_first'] . " " . $result3['name_last'];
                        if ($name == " ") {
                            $name = "Unknown TA";
                        }
                        $_SESSION['ta_name'] = $name;
                        $_SESSION['tadept'] = $result3['department'];
                        $_SESSION['noob'] = 'TRUE';
                        // go to next page.
                        session_regenerate_id(true);
示例#2
0
 $username = trim($username);
 if (empty($username)) {
     try_again("Please enter a username.", $username, "staff");
 } else {
     if (empty($password)) {
         try_again("Please enter a password.", $username, "staff");
     } else {
         try {
             //open db
             $db = new PDO(DB_PATH, DB_LOGIN, DB_PW);
             $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
             $sql = "select count(*) from login_staff where username = '******' and password = '******'";
             $result = $db->query($sql)->fetch();
             if ($result[0] == 0) {
                 //you were just plain wrong.
                 try_again("Username/password pair not found.", $username, "staff");
             } else {
                 //you had a valid login
                 // get TA ID and name for the entire session.
                 session_start();
                 $_SESSION['name'] = $username;
                 $sql = "select department from login_staff where username = \"{$username}\";";
                 $result = $db->query($sql)->fetch();
                 $_SESSION['dept'] = $result['department'];
                 // go to next page.
                 session_regenerate_id(true);
                 session_write_close();
                 header("Location:quarterstaff.php");
                 exit;
             }
         } catch (PDOException $e) {