public function actionRegister() { $uri = trim($_SERVER['REQUEST_URI'], '/'); $errors = false; $result = false; $last_name = ''; $first_name = ''; $login = ''; $email = ''; $date = ''; $phone = ''; if (isset($_POST['submit'])) { $last_name = $_POST['last_name']; $first_name = $_POST['first_name']; $password = $_POST['password']; $login = $_POST['login']; $email = $_POST['email']; $date = date("Y-m-d", strtotime($_POST['date'])); $phone = $_POST['phone']; /* * Валидация данных */ if (RegisterValidator::required(array($_POST))) { $errors[] = 'Все поля обязательны к запонению'; } if (RegisterValidator::checkPassword($password)) { $errors[] = 'Пароль не должен быть короче 6 символов и длинее 16'; } if (RegisterValidator::checkLogin($login)) { $errors[] = 'Такой логин уже существует'; } if (!RegisterValidator::checkEmail($email)) { $errors[] = 'Введите правильный email'; } if (RegisterValidator::checkEmailExists($email)) { $errors[] = 'Такой email уже существует'; } if (!strtotime($_POST['date'])) { $errors[] = 'Введите дату в правильном формате(год-месяц-день)'; } if ($errors == false) { $password = password_hash($password, PASSWORD_DEFAULT); $result = User::postRegister($last_name, $first_name, $password, $login, $email, $date, $phone); } } require_once ROOT . '/views/auth/register.php'; }
<!--<button type="button" class="button" id="fb-login">Facebook Login</button> --><button type="submit" class="button reg">Register</button> </form> </div> </div> </div> <!-- /container --> <?php } } else { require './database.php'; require './class/user.php'; $newuser = new User($db); if (isset($_POST['authentication'])) { $result = $newuser->postRegister($_POST['authentication'], $_POST['password']); if ($result) { $msg = "Successful Confirmation"; $submsg = "Facebook users: You may login via Facebook Login Button or E-mail Address + Password."; } else { $msg = "Error occurs"; } } else { $fbid = isset($_POST['fb']) ? $_POST['fb'] == "1" ? $_POST['fbId'] : NULL : NULL; if ($newuser->duplicate_uname($_POST['username'], $_POST['fbId'], $_POST['displayname'])) { $msg = "Account exist or name has been used"; } else { //($username, $password, $email, $dob, $phone, $mphone, $pDesc) if (isset($_POST['referLink'])) { $refer = $_POST['referLink']; } else {