如何在Laravel中显示客户端的错误

时间:2016-04-06 10:24:39

标签: php laravel-4 server client

如何在Laravel 4.2中使用Laravel控制器在客户端显示错误?

我想显示此错误:

  

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

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('/');
        }
    }
}

这是HTML代码:

<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>

0 个答案:

没有答案