登録フォームを作成します。だから、私はRegShortController.php
ファイルを作成した後、RegShort.blade.php
というビューファイルを作成した。 RegShortController.php
ファイルでは、insertという関数を使用しました。 ",
PW ) values (, ,))
SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'name' cannot be null (SQL: insert into
学術(
名,
ユーザ名"LaravelとMySqlエラーを解決する方法SQLSTATE [23000]
だから、どのようにこの問題を解決するには
?? - 私はウェブサイトを実行する場合でも、私はこのエラーを得ました
は、ここで私は、このスレッドを編集するときRegShort.blade.phpは、残念ながら、私が削除した名前は、ユーザー名とパスワードの属性
ファイルです。今、私はそれを修正しました。ここで
<form action="{{ route('RegShort') }}" method="post" enctype="multipart/form-data"> {{ csrf_field() }} <div class="form-group"> <label>Name : *</label> <input type="text" class="form-control" name="name"> </div> <div class="form-group"> <label>Username : *</label> <input type="text" class="form-control" name="username" required> </div> <div class="form-group"> <label>Password : *</label> <input type="password" class="form-control" name="password"> </div> <button type="submit" class="btn btn-primary" name="submit">Submit</button> </form>
RegShortController.phpはここ
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; use DB; class RegShortController extends Controller { public function index() { return view('RegShort'); } function insert(Request $req) { $name = $req->input('name'); $username = $req->input('username'); $password = $req->input('password'); $data = array("name"=>$name,'username'=>$username,"pw"=>$password); DB::table('academic')->insert($data); } }
ファイルである私が作成したルートです。
Route::any('/RegShort', '[email protected]')->name('RegShort');
名の欄に値を割り当てるか、あなたは 'Model'を使用していない理由を表 – scaisEdge
から制約を削除しますか..? –
あなたは 'username'入力または' password'入力の 'name'属性を持っていません。これは、それらの入力のデータが要求には含まれていないことを意味します。 –