Created
August 11, 2014 08:18
-
-
Save abdullahbutt/a543e581441bf9c78bdf to your computer and use it in GitHub Desktop.
laravel creating a registration form
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Creating a Registration Form | |
//Laravel has ability to use a different route for get and post without going to a different page | |
// Ideally the default value of field "remember_token" in "users" table should be "Null", if you get an error | |
// Hash::make() is a Laravel function which implements security on password & needs 128 length in db table | |
// To Create a Form, use below code in 'register.blade.php' | |
<h2>New User Registration</h2> | |
{{ Form::open(array('url'=>'register')) }} | |
{{ Form::label('email','E-mail') }} | |
{{ Form::text('email') }} | |
{{ Form::label('username','Name') }} | |
{{ Form::text('username') }} | |
{{ Form::label('password','Password') }} | |
{{ Form::text('password') }} | |
{{ Form::submit('Sign Up') }} | |
{{ Form::close() }} | |
// To Create a Form & submit it in db table, below will be the Route | |
Route::get('/register', function() | |
{ | |
return View::make('register'); | |
}); | |
Route::post('/register', function () | |
{ | |
$user=new User; | |
$user->email= Input::get('email'); | |
$user->username= Input::get('username'); | |
$user->password= Hash::make(Input::get('password')); | |
// Hash::make() is a Laravel function which implements security on password & needs 128 length in db table | |
$user->save(); | |
$theEmail= Input::get('email'); | |
return View::make('thanks')->with('theEmail',$theEmail); // this means pick value of variable $theEmail to | |
display in thanks notice | |
}); | |
// Then for thanks sign up page, use below code in "thanks.blade.php | |
<h1>Sign Up!</h1> | |
<article class="post"> | |
<h2>Thanks for Registering</h2> | |
<p> | |
You will shortly receive e-mail at {{ $theEmail }} | |
</p>" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment