Example #1
0
 public function actionSave()
 {
     /*
      * Валидация данных
      */
     $data_array = $_POST;
     /*
      * Заполнение свойств пользователя
      */
     if (!empty($data_array)) {
         $data_array = Auth::verifyData($data_array, 'reg');
         if (!$data_array) {
             header('Location: ' . BASE_PATH . 'auth/register/');
         }
         $user = new Users();
         $user->email = $data_array['email'];
         $user->password = md5(md5($data_array['password']));
         $user->save();
         $user = Users::findOneByColumn('email', $data_array['email']);
         $user->setProfile();
     } else {
         header('Location: ' . BASE_PATH);
     }
     header('Location: ' . BASE_PATH . 'auth/');
 }
Example #2
0
<?php

include 'authentication-class.php';
include 'conntodb.php';
session_start();
if (!empty($_POST)) {
    // first check that both the email, password and form token have been sent
    if (!isset($_POST['email'], $_POST['password'], $_POST['form_token'], $_POST['fname'], $_POST['lname'])) {
        echo '<h3>Please enter all required information</h3>';
    } elseif ($_POST['form_token'] != $_SESSION['form_token']) {
        echo '<h3>Invalid form submission</h3>';
    } elseif (Auth::verifyData($_POST['email'], $_POST['password'])["result"] != true) {
        echo "<h3>" . Auth::verifyData($_POST['email'], $_POST['password'])["verifyData"] . "</h3>";
    } else {
        //if a user is logged in, logg them out before submitting
        if (isset($_SESSION['user'])) {
            Auth::logout();
        }
        // FILTER_SANITIZE_STRING removes junck ASCII characters
        $fname = filter_var($_POST['fname'], FILTER_SANITIZE_STRING);
        $lname = filter_var($_POST['lname'], FILTER_SANITIZE_STRING);
        $email = filter_var($_POST['email'], FILTER_SANITIZE_STRING);
        $password = filter_var($_POST['password'], FILTER_SANITIZE_STRING);
        $auth = new Auth();
        $result = $auth->registerUser($fname, $lname, $email, $password, $conn);
        //redirect to login
        if (isset($result["result"]) && $result['result']) {
            header("Location: http://olemissaitp.azurewebsites.net/login.php");
        } else {
            echo '<h3>' . $result["registerUser"] . '</h3>';
            //Display error message