<?php define('DS', DIRECTORY_SEPARATOR); // separator define('ROOT', dirname(__FILE__)); //root directory require_once ROOT . DS . 'config' . DS . 'config.php'; require_once ROOT . DS . 'classes' . DS . 'autoload.php'; $isave = 0; if (isset($_POST['txtfname'])) { $isave = 1; if (trim($_POST['txtfname']) && trim($_POST['txtage']) && trim($_POST['txtemail'])) { $obj = new Model(); if ($obj->register($_POST)) { $message = "User Info successfully saved"; } else { $message = "Server Error"; } } else { $message = "Please fill up your name,age,email"; } } ?> <!DOCTYPE html> <html lang="en-US"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1"> <meta name="description" content="example"> <meta name="keywords" content=""> <title>Browser Tab</title>
header("Location: login.php"); } } elseif (isset($_POST['registerUsername']) && isset($_POST['registerPassword'])) { $username = $_POST['registerUsername']; //not seen by user in HTML view $password = $_POST['registerPassword']; //not seen by user in HTML view $firstname = htmlspecialchars(trim($_POST['registerFirstName'])); $lastname = htmlspecialchars(trim($_POST['registerLastName'])); $publication = htmlspecialchars(trim($_POST['registerPublication'])); if ($modelMethods->usernameExists($username)) { session_start(); $_SESSION['registrationError'] = 'Username has already been taken'; header("Location: register.php"); } else { $modelMethods->register($username, $password); $modelMethods->addReviewer($username, $firstname, $lastname, $publication); header("Location: index.php"); } } elseif (isset($_POST['logout'])) { //NOT NEEDED FOR OUR IMPLEMENTATION OF LOGOUT session_start(); // to ensure you are using same session session_destroy(); // destroy the session so $SESSION['anything'] is not set header("Location: index.php"); } elseif (isset($_POST['newTitle'])) { $title = htmlspecialchars(trim($_POST['newTitle'])); //UPLOAD IMAGE if (!isset($_FILES['file']['error']) || $_FILES['file']['error'] !== UPLOAD_ERR_OK) { die("Upload failed with error");
<?php session_start(); include $_SERVER['DOCUMENT_ROOT'] . '/Message-Board/db.inc.html.php'; include $_SERVER['DOCUMENT_ROOT'] . '/Message-Board/model.html.php'; if (isset($_GET['register'])) { $registerArray = array('user_name' => $_POST['user_name'], 'user_password' => $_POST['user_password'], 'user_email' => $_POST['user_email']); $Model = new Model(); $Model->register($registerArray); } if (isset($_GET['login'])) { $user_name = $_POST['user_name']; $user_password = $_POST['user_password']; $Model = new Model(); $login = $Model->checkLogin($user_name, $user_password); if (isset($login)) { //判断登录的用户名和密码是否正确 //放用户信息 if ($_POST['user_name'] != "administrator") { $_SESSION['user_name'] = $_POST['user_name']; header('Location: main/get.php'); exit; } else { header('Location: administrator/get.php'); exit; } } else { $error = '用户名和密码出错'; include 'error.html.php'; exit; }