Gammer
Gammer

Reputation: 5608

Laravel 5 : link to php page

I have two pages login.blade.php and register.blade.php. On my login.blade.php i have link to register.blade.php like this :

<a href="register.php">Register a new membership</a>

When i click on the link to register.php it throws the following error :

NotFoundHttpException in RouteCollection.php line 143:

Both login and register are in the same views folder.

My route.php file have :

Route::get('/register', function(){
    return view('register');
});

Upvotes: 3

Views: 24561

Answers (2)

Zahoor Ahmed
Zahoor Ahmed

Reputation: 11

At first give a name to your route and then use it in then use it in anchar tag

Route::get('/', function () {
    return view('welcome');
})->name('welcome');
Route::get('/about', 'PagesController@about')->name('about');

Now you can use it in any page to refer them. like in contact page

<html>
..
....
<a href="{{route('welcome')}}">Home</a>
<a href="{{route('about')}}">About</a>

Upvotes: 1

davsp
davsp

Reputation: 2179

Two things need to happen:

1) Remove the .php in your tag. It should be as such:

<a href="register">Register a new membership</a>

2) Make sure you are catching the 'register' route properly:

Route::get('register', function()
{
    return view('register');
});

Upvotes: 11

Related Questions