douba05167 2014-12-30 18:35
浏览 27
已采纳

laravel没有加载我的表格部分?

im trying to build a user login and registration form and this is my route :

Route::get('/register', function()
{
    return View::make('register');
});

Route::get('/register', function()
{
    $user = new User;
    $user->username = Input::get('username');
    $user->password = Hash::make(Input::get('password'));
    $user->save();
    $username = Input::get('username');
    return View::make('registered')->with('username',$username);
});

and this is my html :

<div class="container">
{{ Form::open(array('url' => 'register', 'class' => 'form-horizontal')) }}
<fieldset>
<!-- Form Name -->
<legend>Form Name</legend>

<!-- Text input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="username"></label>
  <div class="col-md-4">
  <input id="username" name="username" type="text" placeholder="" class="form-control input-md" required="">

  </div>
</div>

<!-- Password input-->
<div class="form-group">
  <label class="col-md-4 control-label" for="password"></label>
  <div class="col-md-4">
    <input id="password" name="password" type="password" placeholder="" class="form-control input-md" required="">

  </div>
</div>

<!-- Appended checkbox -->
<div class="form-group">
  <label class="col-md-4 control-label" for="appendedcheckbox">  </label>
  <div class="col-md-4">
    <div class="input-group">
      <input id="appendedcheckbox" name="appendedcheckbox" class="form-control" type="text" placeholder="">
            <span class="input-group-addon">
          <input type="checkbox">
      </span>
    </div>

  </div>
</div>


<!-- Button -->
<div class="form-group">
  <label class="col-md-4 control-label" for="submit"> </label>
  <div class="col-md-4">
    <button id="submit" name="submit" class="btn btn-inverse"> </button>
  </div>
</div>

</fieldset>
  </div>

few problems :

1. my form does not loads and i see just

the last button for submitting the form and : ' you have registered in $username ' which i design to loads AFTER user submitted

2.my localhost:8000 loaded laravel first page one time but when i began to work on the project i just receiving blank white page and currently accessing my file like this : http://localhost/vendor/bin/crm/public/register

3. is hashing in laravel secure enough? or should i do something else ?

4. my way of doing this is alright or there is a better way for login and reg using laravel ?

  • 写回答

1条回答 默认 最新

  • dqy0707 2014-12-30 18:46
    关注

    You have two routes responding to get requests on /register. Change the second one to Route::post(...) and I would also change both to just register. There isn't a need to prepend a slash onto your routes.

    Hashing in Laravel is secure and shouldn't be something you have to worry about.

    There really isn't a "right" way of doing things, it really depends on how the rest of your app works, how complicated it is, and how easy it should be to maintain. If it were me though, I would have a LoginController with a method for showing the view and a method for creating the user and have those methods respond to the request rather than putting everything right in your routes.php file.

    You are also missing a {{ Form::close() }} at the end of your view as well.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?