this is my blade file @csrf name @if ($errors->has('name')) {{ $errors->first('name') }} @endif
<div class="form-group col-md-6">
<label>email</label>
<input type="email" name="email" class="form-control" id="email" placeholder="Enter your email" required autofocus>
@if ($errors->has('email'))
<span class="Enter properly">{{ $errors->first('email') }}</span>
@endif
</div>
<div class="form-group col-md-6">
<label>Mobile-no</label>
<input type="text" name="mobile-no" class="form-control" id="mobile_no" placeholder="Enter your mobile no" required>
@if ($errors->has('mobile-no'))
<span class="Enter 10digits">{{ $errors->first('mobile_no') }}</span>
@endif
</div>
<div class="form-group col-md-6">
<label>Password</label>
<input type="password" name="password" class="form-control" id="password" placeholder="Enter your password" required>
@if ($errors->has('password'))
<span class="Enter properly">{{ $errors->first('password') }}</span>
@endif
</div>
<div class="form-group col-md-6">
<label>Confirm-password</label>
<input type="password" name="confirm_password" class="form-control" id="confirm_password" placeholder="Re-enter your password" >
</div>
<div class="form-group col-md-6" align="center">
<button class="btn btn-success" style="width:80px;">Submit</button>
</div>
</div>
</div>
</form>
@endsection
This is my controller file
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\FormController;
use Illuminate\Http\Request;
use Hash;
use Session;
use App\Models\User;
use Illuminate\Support\Facades;
class FormController extends Controller
{
public function index()
{
return view ('login');
}
public function postLogin(Request $request)
{
$request->validate([
'email' => 'required',
'password' => 'required',
]);
$credentials = $request->only('email', 'password');
if (User::attempt($credentials)) {
return redirect()->intended('dashboard')
->withSuccess('Signed in');
}
return redirect("login")->withSuccess('Login details are not valid');
}
public function registration()
{
return view('registration');
}
public function postRegistration(Request $request)
{
$request->validate([
'name' => 'required',
'email' => 'required',
'mobile_no' => 'required',
'password' => 'required|min:6',
'confirm_password' => 'required',
]);
$data = $request->all();
$check = $this->create($data);
return redirect("dashboard")->withSuccess('have signed-in');
}
public function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => Hash::make($data['password'])
]);
}
public function dashboard()
{
if(User::check()){
return view('dashboard');
}
return redirect("login")->withSuccess('are not allowed to access');
}
public function signOut()
{
Session::flush();
User::logout();
return Redirect('login');
}
}
//this is my route file
Route::get('dashboard', [FormController::class, 'dashboard']);
Route::get('login', [FormController::class, 'index'])->name('login');
Route::post('post-login', [FormController::class, 'postLogin'])->name('login.post');
Route::get('registration', [FormController::class, 'registration'])->name('register');
Route::post('post-registration', [FormController::class, 'postRegistration'])->name('register.post');
//this is my migration
<?php
use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;
return new class extends Migration
{
public function up()
{
Schema::create('customRegistration', function (Blueprint $table) {
$table->increments('id');
$table->integer('user_id');
$table->string('name');
$table->string('email');
$table->integer('mobile_no');
$table->string('password');
$table->string('confirm_password');
$table->timestamps();
});
}
public function down()
{
Schema::drop('form');
}
}
i created simple laravel login & registration form.laravel is not genrating errors. but it is not stored a data into the database i.e any of data will be not stored in database.
Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.
Find the answer in similar questions on our website.
Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.
PHP (from the English Hypertext Preprocessor - hypertext preprocessor) is a scripting programming language for developing web applications. Supported by most hosting providers, it is one of the most popular tools for creating dynamic websites.
The PHP scripting language has gained wide popularity due to its processing speed, simplicity, cross-platform, functionality and distribution of source codes under its own license.
https://www.php.net/
Laravel is a free open source PHP framework that came out in 2011. Since then, it has been able to become the framework of choice for web developers. One of the main reasons for this is that Laravel makes it easier, faster, and safer to develop complex web applications than any other framework.
https://laravel.com/
Welcome to the Q&A site for web developers. Here you can ask a question about the problem you are facing and get answers from other experts. We have created a user-friendly interface so that you can quickly and free of charge ask a question about a web programming problem. We also invite other experts to join our community and help other members who ask questions. In addition, you can use our search for questions with a solution.
Ask about the real problem you are facing. Describe in detail what you are doing and what you want to achieve.
Our goal is to create a strong community in which everyone will support each other. If you find a question and know the answer to it, help others with your knowledge.