function second_form_test_success()
{
    global $errors;
    $_POST['test'] = "";
    $_POST['addresslineone'] = "add";
    $_POST['addresslinetwo'] = "ress";
    $_POST['city'] = "city";
    $_POST['county'] = "";
    $_POST['postcode'] = "postcode";
    $_POST['country'] = "country";
    $_POST['phonenumber'] = " 1 2   3 4  5 ";
    //it should trim this
    process_second_form();
    //assert(isset($_POST['test']));
    //  Assert that mock input is valid
    assert(empty($errors), "Expected \$errors to be empty");
    assert($_POST['phonenumber'] == "12345");
    //assert($_SESSION contains all the fields expected);
}
Esempio n. 2
0
<?php

//  Dependencies
require_once '../includes/dbconnection.php';
require_once '../includes/session.php';
require_once '../includes/navigation.php';
require_once '../includes/validation_functions.php';
require_once '../includes/form_processing.php';
require_once "../includes/output.php";
//  Process form from signup.php:
if (isset($_POST['submit'])) {
    //Processes form content and redirects with error feedback if needed
    process_first_form();
    //  Process form from address.php
} elseif (isset($_POST['second_submit']) && isset($_SESSION['user_details'])) {
    process_second_form();
    //  Double check for success of previous form submission before prcoeeding
    //  to send data to the database
    if (isset($_SESSION['user_details']) && isset($_SESSION['address_details'])) {
        if (create_new_user()) {
            //must attempt login in order to get the userId generated from the
            //database logic
            $user = attempt_login($_SESSION['email'], $_SESSION['password']);
            if ($user) {
                //login successful
                //restart the session
                clear_session();
                //$_SESSION['logged_in'] = 1;
                $_SESSION['role'] = $user['role'];
                $_SESSION['userId'] = $user['userId'];
                $_SESSION['email'] = $user['email'];