how to show errors to client side

隐身守侯 提交于 2019-12-13 05:25:28

问题


D:\xampp\htdocs\guestlara\app\views\index.php(51): Illuminate\Exception\Handler->handleError(8, 'Undefined varia...', 'D:\xampp\htdocs...', 51, Array)

Page showing above error. How to show this to client

public function login_user()
        {

            $rules = array(
                            'email'=> 'Required|Between:3,64|Email|Unique:users',
                            'password'=>'Required|AlphaNum|Between:4,8|Confirmed',
                            );
            $validator = Validator::make(Input::all(), $rules);

        if ($validator->fails()) {

                                // get the error messages from the validator
                                $messages = $validator->messages();
                                log::error($messages);
                                // redirect our user back to the form with the errors from the validator
                                return Redirect::to('/')
                                    ->withErrors($validator);


            } else {

                        // attempt to do the login
                        if (Auth::attempt($users)) {

                            return Redirect::to('dashboard');

                        } else {        

                            return Redirect::to('/');

                        }

                   }


        }

<form action="login_user" method="post">
                            <div class="alert alert-info">
                                Message
                            </div>
                            <div class="form-group">
                                <label for="email">Email address</label>
                                <input  class="form-control" name="email" placeholder="Enter Email Address" />
                                <div class="error"><?php echo $messages; ?></div>
                            </div>
                            <div class="form-group">
                                <label for="password">Password</label>
                                <input  class="form-control" name="password" placeholder="Enter Password" />
                                <div class="error"><?php echo $messages; ?></div>
                            </div>

                            <input type="submit" name="submit" value="Login" class="btn btn-default">

                            &nbsp; &nbsp;<a href="register"><input type="button" name="register" value="Register" class="btn btn-default"></a>
                            &nbsp;&nbsp;<a href="forgot-password"><input type="button" name="forgot-password" value="forgot-password" class="btn btn-default"></a>                                          
                        </form>

来源:https://stackoverflow.com/questions/36451263/how-to-show-errors-to-client-side

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!