1
votes

i'm using laravel 5.2 and i'm trying to define routes, but i don't know why i get NotFoundHttpException when i try to do post.

<form action="POST" action="post_to_me">
    <input type="text" name="name" >
    <input type="submit">
</form>

this is my form, very simple.

route::post('post_to_me',function(){
    echo "post";
});

here i define the route to post, but when i run tha app, NotFoundHttpException comes out. Does anyone know why?

1
Please write in english - porloscerros Ψ
@porloscerrosΨ ready - Javier Martinez Barriga
Try adding a slash before the uri action="/post_to_me" or use the url() helper action="{{ url('post_to_me') }}" - porloscerros Ψ
thank you, but I still get the error - Javier Martinez Barriga
i already solved it, i wrote action="POST" instead of method="POST"😂 - Javier Martinez Barriga

1 Answers

0
votes

I think you have missed adding the CSRF Token to your form. Try adding

    // Vanilla PHP
<?php echo csrf_field(); ?>

or

// Blade Template Syntax
    {{ csrf_field() }}

just below your form tag