本文整理汇总了PHP中UserDAO::createUser方法的典型用法代码示例。如果您正苦于以下问题:PHP UserDAO::createUser方法的具体用法?PHP UserDAO::createUser怎么用?PHP UserDAO::createUser使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类UserDAO
的用法示例。
在下文中一共展示了UserDAO::createUser方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: executeNew
public function executeNew(sfWebRequest $request)
{
if ($request->getMethod() != "POST") {
return;
}
$this->username = $request->getPostParameter("username");
if (!$this->username) {
return $this->setErrorMsg("Username is a required field!");
}
$this->user = UserDAO::getUser($this->username);
if ($this->user) {
return $this->setErrorMsg("That username is already in use!");
}
$this->password1 = $request->getPostParameter("password1");
$this->password2 = $request->getPostParameter("password2");
if (!$this->password1 || !$this->password2) {
return $this->setErrorMsg("Password is a required field");
}
if ($this->password1 != $this->password2) {
return $this->setErrorMsg("Password and password confirm must match!");
}
$this->email = $request->getPostParameter("email");
$this->user = UserDAO::createUser($this->username, $this->password1, $this->email);
$this->login($this->user);
$this->redirect("dashboard/index");
}
示例2: checkNewUser
public function checkNewUser($username, $name, $surname, $email, $password)
{
switch (FALSE) {
case check_valid_input($username, 6):
throw new InvalidInputException("false Username Input = input needs to be minimum 6 long, only numbers, letters, capital letters and # @ . - or _");
case check_valid_input($name, 1):
case check_no_numbers($name):
throw new InvalidInputException("false name Input = input needs to be minimum 1 long, only letters, capital letters and # @ . - or _");
case check_valid_input($surname, 1):
case check_no_numbers($surname):
throw new InvalidInputException("false surname Input = input needs to be minimum 1 long, only letters, capital letters and # @ . - or _");
case check_valid_input($email, 6):
case check_at($email):
throw new InvalidInputException("false email Input = input needs to be minimum 6 long, only numbers, letters, capital letters and # @ . - or _");
case check_password($password):
throw new InvalidInputException("false password Input = input needs to be minimum 6 long, only numbers, letters, capital letters and # @ . - or _");
}
$hashedpwd = passwordEncrypt($username, $password);
$userDAO = new UserDAO();
$userDAO->createUser($username, $name, $surname, $email, $hashedpwd);
}
示例3: array
var_dump($resultSet);
$lijst = array();
foreach ($resultSet as $rij) {
$u = new User($rij["gebruikersnaam"], $rij["wachtwoord"]);
array_push($lijst, $u);
}
var_dump($lijst);
$dbh = null;
return $lijst;
}
}
$userDAO = new UserDAO();
$users = $userDAO->getAll();
var_dump($users);
$userDOA = new UserDAO();
$newUser = $userDAO->createUser("liesenborghs", "testpwd");
var_dump($newUser);
//class UserService {
//
// public function storeUser($username, $password) {
// $userDAO = new UserDAO();
// $userDAO->createUser($username, $password);
// }
//
// public function checkUser($username, $password) {
// $count = 0;
// $userDAO = new UserDAO();
// $userDAO->getAll();
//
// foreach ($userDAO as $user) {
// if ($user->getUsername() == $username && $user->getPassword() == $password) {
示例4: storeUser
public function storeUser($username, $password)
{
$userDAO = new UserDAO();
$userDAO->createUser($username, $password);
}
示例5: storeUser
public function storeUser($username, $password)
{
$userDAO = new UserDAO();
$newUser = $userDAO->createUser($username, $password);
return $newUser;
}
示例6: password
if ($passwd != $passwd2) {
$warnings[] = "Passwords don't match";
}
if (!isValidPassword($passwd)) {
$warnings[] = "Not a valid password (longer than " . MIN_PASSWORD_LENGTH . " characters required)";
}
if (!isValidUsername($username)) {
$warnings[] = "Not a valid username (longer than " . MIN_USERNAME_LENGTH . " characters required)";
}
// No warnings means everything is in order, and we can create the user
if (count($warnings) == 0) {
$dao = new UserDAO();
if ($dao->userExists($username)) {
$warnings[] = "Username already taken";
} else {
$passwd = pw_encode($passwd);
if (!$dao->createUser($username, $passwd)) {
$warnings[] = "Failed to insert to database";
} else {
// Registration was successful, redirect the user to
// the login screen
$session->set('register_flag', true);
header("Location: login.php");
exit;
}
}
}
}
}
// Include the HTML template:
require __DIR__ . '/../templates/register.php';