samedi 24 février 2018

how to pass value from input form into another page in laravel

Excuse me, i'm new in learning about Laravel and I have a problem about show data value from form input. I have create.blade.php :

@extends('layouts.master')

@section('content')

<div class="container">
    <div class="header">
        <h1><b>Create an account</b></h1>
        <h5>Welcome to Konoha Village</h5>
    </div>
    

    @if(isset($name))
    <div class="alert alert-warning alert-dismissible" role="alert">
        Halo <strong></strong>
        <button type="button" class="close" data-dismiss="alert" aria-label="Close">
            <span aria-hidden="true">$times;</span>
        </button>
    </div>
    @endif

    <div class="form">
        <form action="" method="post" id="form1">
            <div class="form-group">
                <input name="name" id="name" class="form-control" placeholder="Your Full Name"/>                
            </div>
            <br>
            <div class="form-group">
                <input style="cursor:pointer" type="submit" class="btn btn-primary" id="submit" value="Show into Dashboard">
            </div>

            <div class="form-group">
            </div>

        </form>
    </div>
</div>
@endsection

and my controller with name AccController.php :

    <?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;

class AccController extends Controller
{
    public function create() {
        return view('home.create');
    }

    public function show(Request $r) {
        $soul = $r ->name;

        $pesan = "Your name is {$r->name}";
    }
}

and my route in web.php :

//route to get play form
Route::get ('start',        'AccController@create' )->name('home.create');
Route::post('final-test',  'AccController@show');

i want to show in another page view that i called show.blade.php :

@extends('layouts.master')

@section('content')

<div>
    
    <h1>Your name is </h1> </div>   

@endsection

nothing's error in the end but it couldn't show the value from the input form, would you help me please? Regards, Aga.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire