Laravel form data redirect to error when try to save on DB -
i have created registration form using laravel, form working well, validations working without validation error, when seek save data, redirects "whoops, looks went wrong." can please help me find error. give thanks you.
form:
{{ form::open(array('url'=>"create-account")) }} <p> {{ form::text('user_name', '', array('placeholder'=>"user name")) }} @if($errors->has('user_name')) <label> {{ $errors->first('user_name') }} </label> @endif </p> <p> {{ form::text('user_email', '', array('placeholder'=>"user email")) }} @if($errors->has('user_email')) {{ $errors->first('user_email') }} @endif </p> <p> {{ form::password('user_password', array('placeholder'=>"user password")) }} @if($errors->has('user_password')) {{ $errors->first('user_password') }} @endif </p> <p>{{ form::submit('register') }}</p> {{ form::close() }}
and controller has code:
class staffcontroller extends basecontroller { public function getaccount() { homecoming view::make('staff.account'); } public function postaccount() { $input = input::all(); $rules = array( 'user_name' => 'required|min:3|max:20|unique:users', 'user_email' => 'required|email|max:50|unique:users', 'user_password' => 'required|min:5' ); $validate = validator::make($input, $rules); if ($validate->fails()) { homecoming redirect::to('create-account') ->witherrors($validate); } else { $user = new user(); $user->user_name = $input['user_name']; $user->user_email = $input['user_email']; $user->user_password = hash::make($input['user_password']); $user->save(); homecoming redirect::to('login') ->with('global', 'your business relationship has been created, please login'); } } }
model:
use illuminate\auth\usertrait; utilize illuminate\auth\userinterface; utilize illuminate\auth\reminders\remindabletrait; utilize illuminate\auth\reminders\remindableinterface; class user extends eloquent implements userinterface, remindableinterface { utilize usertrait, remindabletrait; /** * database table used model. * * @var string */ protected $table = 'users'; /** * attributes excluded model's json form. * * @var array */ //protected $hidden = array('password', 'remember_token'); protected $hidden = array('user_password'); }
db table has fields:
table name: users fields: user_id int(11) user_name varchar(20) user_email varchar(50) user_password varchar(60) status
routes:
route::get('/','homecontroller@getindex'); route::get('login','homecontroller@getindex'); route::post('login','homecontroller@postlogin'); route::get('create-account', 'staffcontroller@getaccount'); route::post('create-account', 'staffcontroller@postaccount');
laravel laravel-4
No comments:
Post a Comment