質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Windows 10

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Laravel 5

Laravel 5は、PHPフレームワークLaravelの最新バージョンで、2014年11月に発表予定です。ディレクトリ構造がが現行版より大幅に変更されるほか、メソッドインジェクションやFormRequestの利用が可能になります。

Q&A

解決済

1回答

485閲覧

laravelをもちいた新規登録画面の作成(windows)

oxyu8

総合スコア23

Windows 10

Windows 10は、マイクロソフト社がリリースしたOSです。Modern UIを標準画面にした8.1から、10では再びデスクトップ主体に戻され、UIも変更されています。PCやスマホ、タブレットなど様々なデバイスに幅広く対応していることが特徴です。

PHP

PHPは、Webサイト構築に特化して開発されたプログラミング言語です。大きな特徴のひとつは、HTMLに直接プログラムを埋め込むことができるという点です。PHPを用いることで、HTMLを動的コンテンツとして出力できます。HTMLがそのままブラウザに表示されるのに対し、PHPプログラムはサーバ側で実行された結果がブラウザに表示されるため、PHPスクリプトは「サーバサイドスクリプト」と呼ばれています。

Laravel 5

Laravel 5は、PHPフレームワークLaravelの最新バージョンで、2014年11月に発表予定です。ディレクトリ構造がが現行版より大幅に変更されるほか、メソッドインジェクションやFormRequestの利用が可能になります。

0グッド

0クリップ

投稿2019/01/27 06:49

編集2019/01/27 07:32

laravelを用いて新規登録画面、ログイン画面を作成しようと思っているのですが
新規登録画面の作成のステップでつまずいています。

(laravel学習帳/チュートリアル/中級/認証画面の自作を参考に作成しています)

登録画面を作成し、新規登録を行おうとすると

Symfony \ Component \ HttpKernel \ Exception \ MethodNotAllowedHttpException
No message

というエラーが発生します。
このエラーが発生した場合ルーティングの部分が間違っている可能性が高いと調べたのですが、どの部分が間違っているのか自分で見つけることが出来ません。
またデータベースにも反映されません。データベースはsqliteを使用しています

よろしくお願いします。
laravelのバージョンは5.5.44です。

以下がコードになります。

UserController.php <?php namespace App\Http\Controllers; use Illuminate\Http\Request; use App\User; class UserController extends Controller { public function getSignup(){ return view('user.signup'); } public function postSignup(Request $request){ $this->validate($request,[ 'name' => 'required', 'namek' => 'required', 'mail' => 'email|required|unique:users', 'password' => 'required|min:4', 'address' => 'required', 'birth' => 'required', ]); $user = new User([ 'name' => $request->input('name'), 'namek' => $request->input('namek'), 'address' => $request->input('address'), 'birth' => $request->input('birth'), 'mail' => $request->input('mail'), 'password' => bcrypt($request->input('password')), ]); $user->save(); return redirect()->route('user.profile'); } public function getProfile(){ return view('user.profile'); } }
web.php <?php /* |-------------------------------------------------------------------------- | Web Routes |-------------------------------------------------------------------------- | | Here is where you can register web routes for your application. These | routes are loaded by the RouteServiceProvider within a group which | contains the "web" middleware group. Now create something great! | */ Route::get('/', function () { return view('welcome'); }); /*Route::get('user/signup', 'UserController@getSignup'); Route::post('user/signup', 'UserController@postSignup'); Route::get('user/profile', 'UserController@getProfile');*/ Route::group(['prefix' => 'user'], function() { Route::get('/signup',[ 'uses' => 'UserController@getSignup', 'as' => 'user.signup' ]); Route::post('/signup',[ 'uses' => 'UserController@postSignup', 'as' => 'user.signup' ]); Route::post('/profile',[ 'uses' => 'UserController@getProfile', 'as' => 'user.profile' ]); });
User.php <?php namespace App; use Illuminate\Database\Eloquent\Model; use Illuminate\Notifications\Notifiable; use Illuminate\Foundation\Auth\User as Authenticatable; class User extends Authenticatable { use Notifiable; /** * The attributes that are mass assignable. * * @var array */ protected $fillable = [ 'name', 'namek','address', 'birth', 'mail', 'password', ]; /** * The attributes that should be hidden for arrays. * * @var array */ protected $hidden = [ 'id', //'remember_token', ]; }
2019_01_25_050924_create_user_table.php <?php use Illuminate\Support\Facades\Schema; use Illuminate\Database\Schema\Blueprint; use Illuminate\Database\Migrations\Migration; class CreateUserTable extends Migration { /** * Run the migrations. * * @return void */ public function up() { Schema::create('user', function (Blueprint $table) { $table->increments('id'); $table->timestamps(); $table->string('name'); $table->string('namek'); $table->string('address'); $table->string('birth'); $table->string('mail'); $table->string('password'); }); } /** * Reverse the migrations. * * @return void */ public function down() { Schema::dropIfExists('user'); } }
master_auth.blade.php <!DOCTYPE HTML> <html lang="ja"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <title>@yield('title')</title> <link href="{{ url('/') }}/dist/css/vendor/bootstrap/css/bootstrap.min.css" rel="stylesheet"><!-- Loading Bootstrap --> <link href="{{ url('/') }}/dist/css/flat-ui.min.css" rel="stylesheet"><!-- Loading Flat UI --> <link href="{{ url('/') }}/css/starter-template.css" rel="stylesheet"><!--Bootstrap theme(Starter)--> <link rel="shortcut icon" href="{{ url('/') }}/dist/img/favicon.ico"> <!--[if lt IE 9]> <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script> <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script> <![endif]--> @yield('styles') </head> <body> @include('partials.header') <div class="container"> @yield('content') </div><!-- /.container --> <footer class="footer"> <div class="container"> <p class="text-muted">認証デモ</p> </div> </footer> <!-- Bootstrap core JavaScript ================================================== --> <script src="{{ url('/') }}/dist/js/vendor/jquery.min.js"></script> <script src="{{ url('/') }}/dist/js/vendor/video.js"></script> <script src="{{ url('/') }}/dist/js/flat-ui.min.js"></script> <script src="{{ url('/') }}/assets/js/prettify.js"></script> <script src="{{ url('/') }}/assets/js/application.js"></script> @yield('scripts') </body> </html>
signup.blade.php @extends('layouts.master_auth') @section('content') <div class="row"> <form action= "/touroku/public/user/profile" method="post" class="form-horizontal" style="margin-top: 50px;"> <div class="form-group"> <label class="col-sm-3 control-label" for="InputName">氏名</label> <div class="col-sm-9"> <input type="text" name="name" class="form-control" id="InputName" placeholder="氏名"> <!--/.col-sm-10---></div> <!--/form-group--></div> <div class="form-group"> <label class="col-sm-3 control-label" for="InputNamek">氏名(カタカナ)</label> <div class="col-sm-9"> <input type="" name="namek" class="form-control" id="InputNamek" placeholder=""> </div> <!--/form-group--></div> <div class="form-group"> <label class="col-sm-3 control-label" for="InputAddress">住所</label> <div class="col-sm-9"> <input type="" name="address" class="form-control" id="InputAddress" placeholder="番地まで"> </div> <!--/form-group--></div> <div class="form-group"> <label class="col-sm-3 control-label" for="InputBirth">生年月日</label> <div class="col-sm-9"> <input type="" name="birth" class="form-control" id="InputBirth" placeholder=""> </div> <!--/form-group--></div> <div class="form-group"> <label class="col-sm-3 control-label" for="InputEmail">メール・アドレス</label> <div class="col-sm-9"> <input type="email" name="mail" class="form-control" id="InputMail" placeholder=""> </div> <!--/form-group--></div> <div class="form-group"> <label class="col-sm-3 control-label" for="InputPassword">パスワード</label> <div class="col-sm-9"> <input type="password" name="password" class="form-control" id="InputPassword" placeholder=""> </div> <!--/form-group--></div> <div class="form-group"> <div class="col-sm-offset-3 col-sm-9"> <button type="submit" class="btn btn-primary btn-block">新規登録</button> </div> <!--/form-group--></div> {{ csrf_field() }} </form> </div> @endsection
profile.blade.php @extends('layouts.master_auth') @section('content') <div style="margin-top: 30px; text-align: center;"><h3>新規登録完了しました。</h3></div> @endsection

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

一番必要なroutes/web.phpとbladeがない。

たぶんRoute::post()と書くところでRoute::get()にしてるだけ。

このルーティングの書き方は動くけどもう古いので公式ドキュメントを見たほうがいい。
https://laraweb.net/tutorial/1872/

旧バージョンの時に書いた記事だから古いのかと思ったけど最近のこれでも思いっきり間違ってるので見ては行けないサイト入り…。
https://laraweb.net/surrounding/4467/

投稿2019/01/27 07:15

kawax

総合スコア10377

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

oxyu8

2019/01/27 07:36

回答ありがとうございます。 サイトを参考にする際は気を付けます。 web.phpとbladeを載せました Route::getをRoute::postに変更すると、ページがしっかりと遷移しました。 しかし、入力したデータがデータベースに反映されません。 どこかコードが間違っているのでしょうか? データベースはSqliteを使用しています。 migrateは行いました C:\xampp\htdocs\touroku> php artisan migrate Migration table created successfully. Migrating: 2014_10_12_000000_create_users_table Migrated: 2014_10_12_000000_create_users_table Migrating: 2014_10_12_100000_create_password_resets_table Migrated: 2014_10_12_100000_create_password_resets_table Migrating: 2019_01_25_050924_create_user_table Migrated: 2019_01_25_050924_create_user_table Migrating: 2019_01_26_002944_people Migrated: 2019_01_26_002944_people
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問