include_once "classes/_answers.php"; session_start(); if (!isset($_SESSION['uid'])) { header('Location: LoginRegistrationForm/login.php'); die("user not logged in"); } else { if (isset($_SESSION['uid'])) { $uid = $_SESSION['uid']; } if (isset($_SESSION['username'])) { $username = $_SESSION['username']; } if (isset($_SESSION['qoffset'])) { $qoffset = $_SESSION['qoffset']; } $qdes = $_POST['qd']; if (strlen($qdes) == 0) { header("Location: ../index.php"); setcookie("zero", 1, time() + 3, "/"); die; } $newq = new _question(); $newq->setDescription($qdes); $newq->setQUid($uid); if ($newq->_insert_db()) { header("Location: ../index.php"); } else { header("Location: ../error.php"); } die; }
static function _get_all_question_by_date() { if (self::$counter == 0) { $connection = _database::get_connection(); $query = "SELECT * FROM `_questions` ORDER BY `_q_time` DESC"; if (!($res = $connection->query($query))) { return false; } else { $i = 0; while ($arr = $res->fetch_array()) { $obj = new _question(); $obj->setQid($arr['_qid']); $obj->setQUid($arr['_q_uid']); $obj->setDescription($arr['_description']); $obj->setCurious($arr['_curious']); $obj->setQTime($arr['_q_time']); self::$_all_question[$i] = $obj; $i++; } } return self::$_all_question; } else { if (self::$counter++ == 10) { self::$counter = 0; } return self::$_all_question; } }