0

I have a login/registration system I am looking to build in Laravel. Currently I am having trouble pulling the information from the form and inputting it into the table. When I submit the form it submits, but the data goes nowhere, I am admittedly new to Laravel.

This is how the form is written:

{{ Form::open() }} @if (Session::get("error")) {{ Session::get("error") }}<br /> @endif {{ Form::label("first_name", "First Name") }} {{ Form::text("first_name") }} {{ $errors->first("first_name") }}<br /> {{ Form::label("email", "Email") }} {{ Form::text('email', Input::old('email')) }} {{ $errors->first("email") }}<br /> {{ Form::label("password", "Password") }} {{ Form::password("password") }} {{ $errors->first("password") }}<br /> {{ Form::label("password_confirmation", "Confirm") }} {{ Form::password("password_confirmation") }} {{ $errors->first("password_confirmation") }}<br /> {{ Form::submit("register") }} {{ Form::close() }} 

The user.register (part of a larger controller) which this POSTs to and GETs from is as follows:

public function register() { return View::make("user/register"); $validation = Validator::make(Input::all(), User::$rules); if ($validation->fails()) { return Redirect::to('register')->withErrors($validation)->withInput(); } $users = new User; $users->first_name = Input::get('first_name'); $users->email = Input::get('email'); $users->password = Hash::make(Input::get('password')); if ($users->save()) { Auth::loginUsingId($users->id); return Redirect::to('profile'); } return Redirect::to('register')-withInput(); } } 

Currently when I submit I get no errors simply a blank redirect to the registration page and nothing ends up in my DB. I am wondering if there is something wrong with my paths? The only other page that is similar to this that I have previously worked on (inputting data to a database) is a page to reset passwords (which works great), but that used a slightly different system through the Auth extension of Laravel.

This I am not familiar with. Can someone point me in the right direction? I have been compiling the knowledge I have gained from guides online but keep ending up in the same place!

Thanks a lot in advance, Anything else you need (models, routes, etc. I just didn't think they were necessary) lemme know!

2
  • If you get a blank page - its probably a 'white screen of death' - and you need to debug the controller function to work out why Commented Aug 8, 2014 at 5:55
  • @TheShiftExchange sorry, not a blank screen, a blank form. The registration form reloads blank. Commented Aug 8, 2014 at 5:57

1 Answer 1

1

Change

return Redirect::to('register')-withInput(); 

to

return Redirect::to('register')->withInput(); 

edit:

oh - here is the problem:

public function register() { return View::make("user/register"); $validation = Validator::make(Input::all(), User::$rules); ... 

remove the "return" function - it should be

public function register() { $validation = Validator::make(Input::all(), User::$rules); ... 
Sign up to request clarification or add additional context in comments.

3 Comments

Seemed to do the same thing still. Thanks, though!
Second suggestion breaks it unfortunately. I point my GET route at the same controller/view. I'm wondering if I should split them?
Yes - they must be split. Currently you are forcibliy returning from the first line - which means the rest of your code is never run. So when the user submits their form it just returns to the page, because that is what you have told it to do!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.