<?php /** * Make sure you started your'e sessions! * You need to include su.inc.php to make SimpleUsers Work * After that, create an instance of SimpleUsers and your'e all set! */ session_start(); require_once dirname(__FILE__) . "/simpleusers/su.inc.php"; $SimpleUsers = new SimpleUsers(); // This simply logs out the current user $SimpleUsers->logoutUser(); header("Location: login.php");
<?php /** * Make sure you started your'e sessions! * You need to include su.inc.php to make SimpleUsers Work * After that, create an instance of SimpleUsers and your'e all set! */ session_start(); require_once dirname(__FILE__) . "/simpleusers/su.inc.php"; $SimpleUsers = new SimpleUsers(); // This is a simple way of validating if a user is logged in or not. // If the user is logged in, the value is (bool)true - otherwise (bool)false. if (!$SimpleUsers->logged_in) { header("Location: login.php"); exit; } // If the user is logged in, we can safely proceed. $userId = $_GET["userId"]; $user = $SimpleUsers->getSingleUser($userId); if (!$user) { die("The user could not be found..."); } $userInfo = $SimpleUsers->getInfoArray($userId); if (isset($_POST["newkey"])) { if (strlen($_POST["newkey"]) > 0) { $SimpleUsers->setInfo($_POST["newkey"], $_POST["newvalue"], $userId); } if (isset($_POST["userInfo"])) { foreach ($_POST["userInfo"] as $pKey => $pValue) { $SimpleUsers->setInfo($pKey, $pValue, $userId); }
<?php /** * Make sure you started your'e sessions! * You need to include su.inc.php to make SimpleUsers Work * After that, create an instance of SimpleUsers and your'e all set! */ session_start(); require_once dirname(__FILE__) . "/simpleusers/su.inc.php"; $SimpleUsers = new SimpleUsers(); // This is a simple way of validating if a user is logged in or not. // If the user is logged in, the value is (bool)true - otherwise (bool)false. if (!$SimpleUsers->logged_in) { header("Location: login.php"); exit; } // If the user is logged in, we can safely proceed. $userId = $_GET["userId"]; $user = $SimpleUsers->getSingleUser($userId); if (!$user) { die("The user could not be found..."); } // Validation of input if (isset($_POST["password"])) { if (empty($_POST["password"])) { $error = "You have to choose a password"; } else { // Input validation is ok, set the password and then redirect $SimpleUsers->setPassword($_POST["password"], $user["userId"]); header("Location: users.php"); exit;
<?php /** * Make sure you started your'e sessions! * You need to include su.inc.php to make SimpleUsers Work * After that, create an instance of SimpleUsers and your'e all set! */ session_start(); require_once dirname(__FILE__) . "/simpleusers/su.inc.php"; $SimpleUsers = new SimpleUsers(); // Login from post data if (isset($_POST["username"])) { // Attempt to login the user - if credentials are valid, it returns the users id, otherwise (bool)false. $res = $SimpleUsers->loginUser($_POST["username"], $_POST["password"]); if (!$res) { $error = "You supplied the wrong credentials."; } else { header("Location: users.php"); exit; } } // Validation end ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <style type="text/css"> * { margin: 0px; padding: 0px; }
<?php /** * Make sure you started your'e sessions! * You need to include su.inc.php to make SimpleUsers Work * After that, create an instance of SimpleUsers and your'e all set! */ session_start(); require_once dirname(__FILE__) . "/simpleusers/su.inc.php"; $SimpleUsers = new SimpleUsers(); // Validation of input and CSRF if (isset($_POST["secretcode"])) { // Make sure that data hasn't been tampered with $csrf = $SimpleUsers->validateToken(); if ($csrf) { // Proceed with the code to be executed if data hasn't been tampered } } // Validation end ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <style type="text/css"> * { margin: 0px; padding: 0px; } body { padding: 30px;
<?php /** * Make sure you started your'e sessions! * You need to include su.inc.php to make SimpleUsers Work * After that, create an instance of SimpleUsers and your'e all set! */ session_start(); require_once dirname(__FILE__) . "/simpleusers/su.inc.php"; $SimpleUsers = new SimpleUsers(); // This is a simple way of validating if a user is logged in or not. // If the user is logged in, the value is (bool)true - otherwise (bool)false. if (!$SimpleUsers->logged_in) { header("Location: login.php"); exit; } // If the user is logged in, we can safely proceed. $userId = $_GET["userId"]; $db_key = urldecode($_GET["db_key"]); $SimpleUsers->removeInfo($db_key, $userId); header("Location: users.php"); exit;
<?php /** * Make sure you started your'e sessions! * You need to include su.inc.php to make SimpleUsers Work * After that, create an instance of SimpleUsers and your'e all set! */ session_start(); require_once dirname(__FILE__) . "/simpleusers/su.inc.php"; $SimpleUsers = new SimpleUsers(); // This is a simple way of validating if a user is logged in or not. // If the user is logged in, the value is (bool)true - otherwise (bool)false. if (!$SimpleUsers->logged_in) { header("Location: login.php"); exit; } // If the user is logged in, we can safely proceed. $users = $SimpleUsers->getUsers(); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <meta http-equiv="content-type" content="text/html; charset=UTF-8" /> <style type="text/css"> * { margin: 0px; padding: 0px; } body { padding: 30px; font-family: Calibri, Verdana, "Sans Serif";
<?php /** * Make sure you started your'e sessions! * You need to include su.inc.php to make SimpleUsers Work * After that, create an instance of SimpleUsers and your'e all set! */ session_start(); require_once dirname(__FILE__) . "/simpleusers/su.inc.php"; $SimpleUsers = new SimpleUsers(); // Validation of input if (isset($_POST["username"])) { if (empty($_POST["username"]) || empty($_POST["password"])) { $error = "You have to choose a username and a password"; } else { // Both fields have input - now try to create the user. // If $res is (bool)false, the username is already taken. // Otherwise, the user has been added, and we can redirect to some other page. $res = $SimpleUsers->createUser($_POST["username"], $_POST["password"]); if (!$res) { $error = "Username already taken."; } else { header("Location: users.php"); exit; } } } // Validation end ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml">
<?php /** * Make sure you started your'e sessions! * You need to include su.inc.php to make SimpleUsers Work * After that, create an instance of SimpleUsers and your'e all set! */ session_start(); require_once dirname(__FILE__) . "/simpleusers/su.inc.php"; $SimpleUsers = new SimpleUsers(); // This is a simple way of validating if a user is logged in or not. // If the user is logged in, the value is (bool)true - otherwise (bool)false. if (!$SimpleUsers->logged_in) { header("Location: login.php"); exit; } // If the user is logged in, we can safely proceed. $userId = $_GET["userId"]; //Delete the user (plain and simple) $SimpleUsers->deleteUser($userId); header("Location: users.php");