Example #1
0
 * 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">
	<head>
		<title></title>
	  <meta http-equiv="content-type" content="text/html; charset=UTF-8" />