【问题标题】:I am new at PHP , I am not able to connect my form with database . NotFoundHttpException in RouteCollection.php line 179:我是 PHP 新手,无法将表单与数据库连接。 RouteCollection.php 第 179 行中的 NotFoundHttpException:
【发布时间】:2017-04-25 00:04:11
【问题描述】:

**请帮助我将表单连接到数据库,表是在数据库中创建的,但我很困惑如何将它与我的表单连接**

这就是我路由表单的方式

      <div id="register" class="animate form">
                        <form action="{{route('signup')}}" method="post" autocomplete="on"> 
                            <h1> Sign up </h1> 

这是我的控制器

public function postSignup(Request $request)
    {
        $username = $request['username'];
        $email = $request['email'];
        $password = bcrypt($request['password']);


        $user = new User();
        $user->username = $username;
        $user->email = $email;
        $user->password = $password;


        $user->save();
        return redirect()->back();

    }

我的路线文件来了:

Route::post('/signup',[
    'uses' => UserController@postSignup,
    'as'=> 'signup'

    ]);

error screenshot

【问题讨论】:

  • 简单的拼写错误,方法名称postSignup 方法名称...。方法名称应与'uses' =&gt; UserController@postSignup, 匹配,看你有大写S,你的方法是小写@987654328 @注册
  • 这不是问题,我已经纠正了它,但没有任何改变 - 它仍然说找不到页面。
  • 可以贴出错误页面的截图吗??
  • 最后一行是错误截图的链接
  • 你的 .env 文件好吗? @saqlainshoaib

标签: php database laravel-5 laravel-5.2


【解决方案1】:

你的表格是这样的:-

 <form action="{{url('signup')}}" method="post" autocomplete="on"> </from>
                                   Or
 <form action="{{ action('UserController@postSignup')}}" method="post" autocomplete="on"> </from>

试试这条路:-

Route::match(['get', 'post'], '/signup', 'UserController@postSignup');

希望对你有帮助!

【讨论】:

    猜你喜欢
    • 2018-07-29
    • 1970-01-01
    • 1970-01-01
    • 2018-02-13
    • 1970-01-01
    • 2018-04-02
    • 1970-01-01
    • 2019-01-09
    • 2016-08-16
    相关资源
    最近更新 更多