Fastest Web Hosting

displaying the error messages in laravel after being redirected from controller

0 votes
asked Nov 5, 2016 in Laravel by punnet (400 points)

My Controller is:

public function registeruser()
{
    $firstname = Input::get('firstname');
    $email= Input::get('email');
    $data  =  Input::except(array('_token')) ;
    $rule  =  array(
                'firstname'       => 'required',
                'lastname'         => 'required',
                   ) ;
    $validator = Validator::make($data,$rule);
    if ($validator->fails())
    {
    $messages = $validator->messages();
    return Redirect::to('/')->with('message', 'Register Failed');
    }
    else
    {
    DB::insert('insert into user (firstname, email) values (?, ?)',
                                array($firstname, $lastname));
    return Redirect::to('/')->with('message', 'Register Success');
    }
    }

Please tell me the solution

1 Answer

0 votes
answered Nov 7, 2016 by anonymous

To display error under each field you can do like this.

<input type="text" name="firstname">
<div class="error">{{ $errors->first('firstname') }}</div>

Job Board

TechnicalSharp is a technical community of developers where they are sharing their knowledge and solutions and against it they are getting the score point which help them to make profile strong which is under eyes on MNC's
...