Skip to content

Instantly share code, notes, and snippets.

@abdullahbutt
Created August 11, 2014 08:18
Show Gist options
  • Select an option

  • Save abdullahbutt/a543e581441bf9c78bdf to your computer and use it in GitHub Desktop.

Select an option

Save abdullahbutt/a543e581441bf9c78bdf to your computer and use it in GitHub Desktop.

Revisions

  1. abdullahbutt created this gist Aug 11, 2014.
    70 changes: 70 additions & 0 deletions laravel creating a registration form
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,70 @@
    //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>"