Support the ongoing development of Laravel.io →
Session Forms Validation

Written with StackEdit.

So i have this issues with displaying my custom errors and validation errors to my view(/register), so i googled an found out that the former process has been updated when i implement mine i get this.

RuntimeException in EncryptionServiceProvider.php line 45:
No supported encrypter found. The cipher and / or key length are invalid.

ROUTES.PHP based on This

Route::group(['middleware' => ['web']], function () {

Route::get('register', function () {
    return view('main_app.register');
});

Route::post('register@processing', array(
  'uses' => 'WsRegisterController@register',
  'as' => 'Ws.register'
  ));
});

KERNEL.PHP

<?php

namespace App\Http;

use Illuminate\Foundation\Http\Kernel as HttpKernel;

class Kernel extends HttpKernel
{
    /**
     * The application's global HTTP middleware stack.
     *
     * These middleware are run during every request to your application.
     *
     * @var array
     */
    protected $middleware = [
        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
        \Illuminate\Session\Middleware\StartSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
    ];

/**
 * The application's route middleware groups.
 *
 * @var array
 */
protected $middlewareGroups = [
    'web' => [
        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \App\Http\Middleware\VerifyCsrfToken::class,
    ],

    'api' => [
        'throttle:60,1',
    ],
];

/**
 * The application's route middleware.
 *
 * These middleware may be assigned to groups or used individually.
 *
 * @var array
 */
protected $routeMiddleware = [
    'auth' => \App\Http\Middleware\Authenticate::class,
    'auth.basic' => \Illuminate\Auth\Middleware\AuthenticateWithBasicAuth::class,
    'guest' => \App\Http\Middleware\RedirectIfAuthenticated::class,
    'throttle' => \Illuminate\Routing\Middleware\ThrottleRequests::class,
];
}

CONTROLLER.PHP

<?php

namespace App\Http\Controllers;

use App\User;
use App\Http\Controllers\Controller;
use App\Wasamar\Userconfirmation;
use Illuminate\Support\Facades\Input;
use Hash;
use Validator;
use Redirect;
use Session;

class WsRegisterController extends Controller
{

public function register()
{
    $wsregistration = Input::all();
    $wsUserName = Input::get('name');
    $wsUserEmail = Input::get('email');
    $wsUserPassword = Input::get('password');

    /* Check if user is a bot */

    $wsrules = [
    // 'g-recaptcha-response' => 'required|recaptcha', capthcha
    'name'   => 'required|min:2|max:32',
    'email'  => 'required|email',
    'password' => 'required|alpha_num|min:8'
    ];

    $wsvalidator = Validator::make($wsregistration, $wsrules);

    if ($wsvalidator->passes()) {

        /* Check if the email address exits */

        $wsUser_count = User::where('email', '=', $wsUserEmail)->count();

        // return $wsUser_count; exit;
        
        if ( $wsUser_count > 1 ) {

            return Redirect::to('/register')-> with(array('error_msg' => 'This email address exist, please use another email address.'));

        }

        /* write to the user table */

        $wsUser = new User;
        $wsUser->name = Input::get('name');
        $wsUser->email = Input::get('email');
        $wsUser->password = Hash::make(Input::get('password'));
        $wsUser->save();


        /* write to the userconfirmation table */

        $wsemail = $wsUser->email;
        $wsname = $wsUser->name;

        $email = $wsUserEmail;

        $users = User::where('email', '=', $email)->first();

        $user_id = $users->id;

        $confirmation_code = str_random(30);


        $wsconfirm = new Userconfirmation;
        $wsconfirm->user_id = $user_id;
        $wsconfirm->confirmed = 0;
        $wsconfirm->confirmation_code = $confirmation_code;
        $wsconfirm->save();

    }
    else{
        return redirect::to('/register')->with($wsrules);
    }


}
}

VIEW.PHP

<div class="form-box">
						<!-- Error message box -->
						<?php
						var_dump(Session::all());
						
						$success_msg = Session::get('success_msg');
						$error_msg = Session::get('error_msg');
						if ( isset($success_msg) ) {
							echo '
							<div data-alert class="alert-box success radius">
							<h6 class="text-center black-text montserrat-font small-text-13">'.$success_msg.'</h6>
							<a href="#" class="close">&times;</a>
							</div>
							';
						}

						if ( isset($error_msg) ) {
							echo '
							<div data-alert class="alert-box alert radius">
							<h6 class="text-center black-text montserrat-font small-text-13">'.$error_msg.'</h6>
							<a href="#" class="close">&times;</a>
							</div>       
							';
						}
						?>
						<!-- /end error message box -->

						<h3 class="text-center go-up-a-bit-20 main-color-no-hover montserrat-font white-text text-shadow">
							Register
						</h3>
						<div class="name-field">
							<input name="name" type="text" required pattern="[a-zA-Z]+" class="go-down-a-bit-20" type="email" required placeholder="Full name (Ada Obi)">
							<small class="error">Name is required and must be a string.</small>
						</div>
						<div class="email-field">
							<input name="email" class="" style="margin-bottom: 20px !important;" class="go-down-a-bit-20" type="email" required placeholder="Email (Someone@example.com)">
							<small class="error">An email address is required.</small>
						</div>
						<div class="password-field">
							<input name="password" id="password" class="go-down-a-bit-20" type="password" required placeholder="Password" pattern="[a-zA-Z]+">
							<small class="error">Password is required (Min:8)and must contain numbers, upper case and lower case characters.</small>
						</div>
						<div class="password-confirmation-field">
							<input name="c-password" type="password" required pattern="[a-zA-Z]+" data-equalto="password" placeholder="Confirm password">
							<small class="error">The password did not match</small>
						</div>
						<div class="toc-field">
							<label for="checkbox1" class="error montserrat-font small-text-13">
								<input type="checkbox" id="checkbox1" required="" data-invalid=""> Do you agree to our <a href="/terms"><i class="footer-links">terms </i></a>?</label>
						</div>
						<!-- 
							Recapcha needed when we go live.
							--------------------------------
						<center>{!! Recaptcha::render() !!}</center>  -->                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   
						<button style="margin-top: 20px !important; margin-bottom: 20px !important;" class="wider-button pb-skeleton-button-transparent pb-skeleton-button-tq-blue" type="submit"> Register </button>
						<hr>
						<h6 class="text-center black-text small-text-13 montserrat-font"> Are you a tailor or fashion designer?</h6>
						<a href="/tailor@registration">
							<button style="margin-bottom: 30px !important;" class="wider-button pb-skeleton-button-transparent pb-skeleton-button-tq-blue" type="button"> Register </button>
						</a>
					</div>

.

Last updated 3 years ago.
0

Just open terminal go to your project and type "php artisan key:generate".

0

@kunalcoder23 I have done that but the error still occur please you can join the conversation here http://stackoverflow.com/questions/37505809/no-supported-encrypter-found-issue?noredirect=1#

0

what are you doing man seriously

'key' => env('o/tPhyhKmuLoJMWXZeV8b10OFoCT62z6WKuC3HO5Jbw='),

'cipher' => 'AES-128-CBC',//'AES-256-CBC',

what is this ?

It should be

'key' => env('APP_KEY'),

'cipher' => 'AES-128-CBC',//'AES-256-CBC',

0

@kunalcoder23 Solved it

'key' => '9TSL9BsEjZyoM9BjX9du0XaLnCDi4m4Z',// env('9TSL9BsEjZyoM9BjX9du0XaLnCDi4m4Z'),

'cipher' => 'AES-256-CBC',

php artisan config:cache

Did the magic.

0

Do it is the direct method man but it is the wrong completely wrong way. Please think coding as a religion and follow it man.

0

lol kunalcoder23 is right though

you're doing it all wrong

0

Sign in to participate in this thread!

PHPverse

Your banner here too?

ubilli ubilli Joined 10 Jun 2014

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2025 Laravel.io - All rights reserved.