1

I am trying to make a form using bootstrap3 in laravel5.1 so that I can get values from user and store it on the database and want to redirect the same page. here is the form part of my code --

<div class="row">
        <form action="{{url('fastshops/menu')}} " method="post" role="form">
            <legend>ADD NEW ITEM</legend>

            <div class="form-group">
                <label for=""></label>
                <input type="text" class="form-control" name="ItemID" id="" placeholder="Item ID...">
                <label for=""></label>
                <input type="text" class="form-control" name="ItemName" id="" placeholder="Item Name...">
                <label for=""></label>
                <input type="text" class="form-control" name="SellPrice" id="" placeholder="Sell Price...">
                <label for=""></label>
                <input type="text" class="form-control" name="NetPrice" id="" placeholder="Net Price...">

            </div>
            <button type="submit" class="btn btn-primary">Submit</button>
        </form>
    </div>

but this part action="{{url('fastshops/menu')}} is not working ! If I click on the submit button I am having TokenMismatchException ! please help me out. thanks in advance.

1 Answer 1

3

add this <input type="hidden" name="_token" value="{{Session::token()}}"/> or <input type="hidden" name="_token" value="{{csrf_token()}}"/> inside your form. Laravel 5 automatically check for CSRF on all Post request for all the routes. Read the docs, they are pretty self explainatory

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.