本文整理汇总了PHP中UserManager::create方法的典型用法代码示例。如果您正苦于以下问题:PHP UserManager::create方法的具体用法?PHP UserManager::create怎么用?PHP UserManager::create使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserManager
的用法示例。
在下文中一共展示了UserManager::create方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: UserManager
<?php
if (isset($_POST['action'])) {
if ($_POST['action'] == "register") {
if (isset($_POST['f-name'], $_POST['l-name'], $_POST['email'], $_POST['emailRepeat'], $_POST['password'], $_POST['passwordRepeat'])) {
$lastname = $_POST['l-name'];
$firstname = $_POST['f-name'];
$email = $_POST['email'];
$emailRepeat = $_POST['emailRepeat'];
$userManager = new UserManager($database);
try {
$data = $userManager->create($_POST['l-name'], $_POST['f-name'], $_POST['password'], $_POST['passwordRepeat'], $_POST['email'], $_POST['emailRepeat']);
} catch (Exception $e) {
$errors[] = $e->getMessage();
}
if (count($errors) == 0) {
$_SESSION['success'] = "Votre inscription est réussite!";
$_SESSION['id'] = $data->getId();
header("Location: index.php");
exit;
} else {
return $errors;
}
}
} else {
if ($_POST['action'] == "connect") {
if (isset($_POST['email'], $_POST['password'])) {
$email = $_POST['email'];
$userManager = new UserManager($database);
try {
$user = $userManager->findByEmail($_POST['email']);
示例2: header
} else {
$user = $retour;
if ($user->verifPassword($_POST['password'])) {
$_SESSION['id'] = $user->getId();
header('Location: index.php');
exit;
} else {
$errors[] = 'Incorrect Password';
}
}
}
} else {
if ($action == 'register') {
if (isset($_POST['login'], $_POST['password1'], $_POST['password2'], $_POST['email'], $_POST['avatar'])) {
$manager = new UserManager($db);
$retour = $manager->create($_POST['login'], $_POST['password1'], $_POST['password2'], $_POST['email'], $_POST['avatar']);
if (is_array($retour)) {
$errors = array_merge($errors, $retour);
} else {
header('Location: index.php?page=login');
exit;
}
}
} else {
if ($action == 'logout') {
session_destroy();
$_SESSION = array();
header('Location: index.php');
exit;
} else {
if ($action == 'edit_profil') {
示例3: header
} else {
$user = $retour;
if ($user->verifPassword($_POST['password'])) {
$_SESSION['id'] = $user->getId();
header('Location: index.php');
exit;
} else {
$errors[] = 'Incorrect Password';
}
}
}
} else {
if ($action == 'register') {
if (isset($_POST['login'], $_POST['password1'], $_POST['password2'], $_POST['email'], $_POST['name'], $_POST['surname'], $_POST['date_birth'])) {
$manager = new UserManager($db);
$retour = $manager->create($_POST['login'], $_POST['password1'], $_POST['password2'], $_POST['email'], $_POST['name'], $_POST['surname'], $_POST['date_birth']);
if (is_array($retour)) {
$errors = array_merge($errors, $retour);
} else {
if (is_string($retour)) {
$errors[] = $retour;
} else {
header('Location: index.php?page=login');
exit;
}
}
}
} else {
if ($action == 'logout') {
session_destroy();
$_SESSION = array();
示例4: UserManager
<?php
if (isset($_GET['page'])) {
// Register function
if ($_GET['page'] == 'register') {
if (isset($_POST['register_email'], $_POST['register_name'], $_POST['register_surname'], $_POST['register_password'], $_POST['register_password2'])) {
$manager = new UserManager($db);
try {
$res = $manager->create($_POST['register_email'], $_POST['register_name'], $_POST['register_surname'], $_POST['register_password'], $_POST['register_password2']);
} catch (Exception $e) {
$errors[] = $e->getMessage();
}
if (count($errors) == 0) {
$_SESSION['success'] = "Registration successful";
header('Location: ?page=login');
exit;
}
}
}
// Login function
if ($_GET['page'] == 'login') {
if (isset($_POST['login_email'], $_POST['login_password'])) {
$userManager = new UserManager($db);
try {
$user = $userManager->readByEmail($_POST['login_email']);
} catch (Exception $e) {
$errors[] = $e->getMessage();
}
if (count($errors) == 0) {
if ($user->checkPassword($_POST['login_password'])) {
$_SESSION['id'] = $user->getId();
示例5: elseif
$login = $_POST['login'];
$email = $_POST['email'];
} elseif ($taille > $taille_maxi) {
$error = 'Le fichier est trop gros.';
$login = $_POST['login'];
$email = $_POST['email'];
} elseif ($error == "") {
//On formate le nom du fichier ici...
$fichier = strtr($fichier, 'ÀÁÂÃÄÅÇÈÉÊËÌÍÎÏÒÓÔÕÖÙÚÛÜÝàáâãäåçèéêëìíîïðòóôõöùúûüýÿ', 'AAAAAACEEEEIIIIOOOOOUUUUYaaaaaaceeeeiiiioooooouuuuyy');
$fichier = preg_replace('/([^.a-z0-9]+)/i', '-', $fichier);
if (move_uploaded_file($_FILES['image']['tmp_name'], $dossier . $fichier) == FALSE) {
$error = 'Echec de l\'upload !';
$login = $_POST['login'];
$email = $_POST['email'];
} else {
$user = $manager->create($_POST['login'], $_POST['email'], $_POST['password'], $dossier . $fichier);
header('Location:' . str_replace('index.php', '', $_SERVER['SCRIPT_NAME']) . 'login');
exit;
}
}
} else {
$error = "Les deux mots de passe ne correspondent pas";
$login = $_POST['login'];
$email = $_POST['email'];
}
} else {
$error = "Le mot de passe doit contenir 6 caractères minimum";
$login = $_POST['login'];
$email = $_POST['email'];
}
}