Altafk Altafk - 1 year ago 166
MySQL Question

SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'EMAIL' cannot be null

I am new to laravel please give the solution
This is user controller code when i submit the form i am getting email is null but i am inserting email.

there is no laravel issue i think its mysql issue

namespace App\http\Controllers;

use App\User;
use Illuminate\Http\Request;

class UserController extends Controller
public function postSignUp(Request $request)
$email = $request['email'];
$first_name = $request['first_name'];
$password = bcrypt($request['password']);

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

$user-> save();

return redirect()-> back();

public function postSignIn(Request $request)


This is migrate table.


use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateUsersTable extends Migration
* Run the migrations.
* @return void
public function up()
Schema::create('users', function (Blueprint $table) {

* Reverse the migrations.
* @return void
public function down()

This is my html file

<div class="row">
<div class="col-md-6">
<h3>Sign Up</h3>
<form action="{{ route('signup') }}" method="post">
<div class="form-group">
<lable for="email">Your Email</lable>
<input class="form-control" type="email" name "email" id="email">
<div class="form-group">
<lable for="first_name">Your first name</lable>
<input class="form-control" type="text" name="first_name" id="first_name">
</div><div class="form-group">
<lable for="password">Your Password</lable>
<input class="form-control" type="password" name "password" id="password">
<button type="submit" class="btn btn-primary">Submit</button>
<input type="hidden" name="_token" value="{{ Session::token() }}">


Route::get('/', function () {
return view('welcome');

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

Answer Source

Your HTML is wrong. Replace:

<input class="form-control" type="text" name "email" id="email">
<input class="form-control" type="password" name "email" id="password">


<input class="form-control" type="email" name="email" id="email">
<input class="form-control" type="password" name="password" id="password">

After that replace your Controller like this:

$email= $request->input( 'email' );