Exemplo n.º 1
0
// if a login session exists, make sure you redirect to the my account page.
if ($page_result_code == SUCCESS_NO_ERROR) {
    // redirect to the 'user_account' page
    // REMEMBER:
    // header() must be called before any actual output is
    // sent, either by normal HTML tags, blank lines in a file, or from PHP.
    // plus addressess must be absolute (we need to change this)
    header("Location: ../user_account/index.php");
} else {
    if ($_SERVER["REQUEST_METHOD"] == "POST") {
        // Create short variable names.
        $user_email = $_POST['user_email'];
        $user_name = $_POST['user_name'];
        $user_password = $_POST['user_password'];
        $user_password2 = $_POST['user_password2'];
        $page_result_code = validate_registration_form($user_email, $user_name, $user_password, $user_password2);
        // if validation was succesful
        if ($page_result_code == SUCCESS_NO_ERROR) {
            $page_result_code = register_user($user_name, $user_email, $user_password);
            if ($page_result_code == SUCCESS_NO_ERROR) {
                $page_message = "registration successful";
                // redirect to the 'login' page
                // REMEMBER:
                // header() must be called before any actual output is
                // sent, either by normal HTML tags, blank lines in a file, or from PHP.
                // plus addressess must be absolute (we need to change this)
                header("Location: ../index.php");
            } else {
                handle_result_code($page_result_code, $page_message);
            }
        } else {
function custom_registration()
{
    //if the form has submitted
    if (isset($_POST["submit"])) {
        //check for errors
        $error = validate_registration_form();
        if ($error == "") {
            //success
            register();
        } else {
            $framework = get_option("framework", "foundation");
            if ($framework == "foundation") {
                show_registration_form_foundation($error);
            } else {
                if ($framework == "bootstrap") {
                    show_registration_form_bootstrap($error);
                }
            }
        }
    } else {
        $framework = get_option("framework", "foundation");
        if ($framework == "foundation") {
            show_registration_form_foundation();
        } else {
            if ($framework == "bootstrap") {
                show_registration_form_bootstrap();
            }
        }
    }
}
Exemplo n.º 3
0
<?php

require_once __DIR__ . "/../config/config.php";
require_once __DIR__ . "/../util/web.php";
require_once __DIR__ . "/../util/security.php";
require_once __DIR__ . "/../service/registration_service.php";
require_once __DIR__ . "/../service/data_service.php";
session_start();
$validationResult = validate_registration_form($_POST);
if (count($validationResult) > 0) {
    $_SESSION["errors"] = $validationResult;
    $url = VIEWS . "/registration_form.php";
    redirect($url);
    exit;
} else {
    $userName = $_POST["userName"];
    $userNameAvailable = verify_username_availability($userName);
    if ($userNameAvailable) {
        $_SESSION["errors"] = array("userName" => "Username already exists");
        $url = VIEWS . "/registration_form.php";
        redirect($url);
        exit;
    }
    $firstName = $_POST["firstName"];
    $lastName = $_POST["lastName"];
    $password = $_POST["password"];
    $user = new_todo_user($firstName, $lastName, $userName, $password);
    if ($user) {
        $_SESSION["success"] = "Registration successful. Please login.";
    }
    redirect(APPLICATION_ROOT . "/index.php");
function custom_registration()
{
    //structure for handling a form
    //if the form has been submitted
    if (isset($_POST["Submit"])) {
        //check for errors
        $error = validate_registration_form();
        if ($error == "") {
            //success
            register();
        } else {
            //get the current framework
            //if it is empty default will be html5
            $framework = get_option("framework", "html5");
            if ($framework == "html5") {
                show_registration_form_html5($error);
            } else {
                if ($framework == "bootstrap") {
                    show_registration_form_bootstrap($error);
                } else {
                    if ($framework == "foundation") {
                        show_registration_form_foundation($error);
                    }
                }
            }
        }
    } else {
        //get the current framework
        //if it is empty default will be html5
        $framework = get_option("framework", "html5");
        if ($framework == "html5") {
            show_registration_form_html5();
        } else {
            if ($framework == "bootstrap") {
                show_registration_form_bootstrap();
            } else {
                if ($framework == "foundation") {
                    show_registration_form_foundation();
                }
            }
        }
    }
    //end else submit
}
Exemplo n.º 5
0
require 'engine/common.php';
// If form has been submitted.
if (isset($_POST['action']) && $_POST['action'] == "Register") {
    // Pass recaptcha
    // Setup recaptcha response object
    $resp = recaptcha_check_answer(RECAPTCHA_PRIVATE_KEY, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]);
    if (!$resp->is_valid) {
        // What happens when the CAPTCHA was entered incorrectly
        $errors = array();
        $errors[] = "The reCAPTCHA wasn't entered correctly.  Go back and try it again.  (reCAPTCHA said: " . $resp->error . ")";
        handle_errors($errors);
        handle_reposts();
    } else {
        // Recaptcha successful, now onto the rest of the form.
        // If form does not validate, we need to return with errors.
        if ($errors = validate_registration_form()) {
            handle_errors($errors);
            handle_reposts();
        } else {
            // If errors occur while trying to create user, we need to return with errors.
            if ($errors = process_registration_form($smarty)) {
                handle_errors($errors);
                handle_reposts();
            } else {
                header("Location: pending.php");
            }
        }
    }
}
$smarty->assign('page_name', 'Site Registration');
$smarty->assign('recaptcha_html', recaptcha_get_html(RECAPTCHA_PUBLIC_KEY));