-2

I try to do a basic form and I did that 1 week ago but this time I have a new bug surely a stupid mistake but...

So here is my UsersController

<?php
  
namespace App\Http\Controllers;
  
use Illuminate\Http\Request;
  
use App\Http\Requests;
use App\Http\Controllers\Controller;
  
class UsersController extends Controller
      
      
{
    public function getInfos()
          
          
    {
        return view('infos');
    }
      
      
    public function postInfos(Request $request)
    {
        return 'His name ' . $request->input('firstname');
 
    }
}

My infos.blade

@extends('template')

@section('contenu')
    {!! Form::open(['url' => 'users']) !!}
        {!! Form::label('frstname', 'Your name : ') !!}
        {!! Form::text('firstanme') !!}
        {!! Form::submit('Send !') !!}
    {!! Form::close() !!}
@endsection

And the web.php

Route::get('users', 'UsersController@getInfos');
Route::post('users', 'UsersController@postInfos');

I use a template but I'm almost sure that's not the problem , I think I do bad routing , I have this error message

syntax error, unexpected 'namespace' (T_NAMESPACE)

Thx to help me :)

ps : the error message enter image description here

22
  • This is not the answer but you have a typo in your code Form::text('firstanme') should be "firstname" Commented Mar 12, 2019 at 15:07
  • 1
    {!! Form::text('firstanme') !! is this a typo?? Commented Mar 12, 2019 at 15:09
  • 2
    Php version? Just checkin' Commented Mar 12, 2019 at 15:10
  • Also, can you please show the full error message? Commented Mar 12, 2019 at 15:11
  • 1
    @Thibaudkhan If you replace public/index.php with <?php echo phpversion(); does it output 7.1? It's not uncommon to have multiple PHP versions on a server. Commented Mar 12, 2019 at 15:44

1 Answer 1

-1

Since ypur namespace suggests the said controller resides in the same directory as the extended controller you dont need to specify this.

Also depending on the laravel version you may require running

php artisan dump:autoload
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.