Hello i am new with laravel so i decide to start with sample examples so i start whit calculator programme: here is the strecture of my application
<form method="POST" action="calc/calc">
Route::controller('calc', 'calcController');
calcController.php => contain 2 methods:
1) getCalc() used with get to send the form return view('calc');
2) postCalc(calcRequest $r) this methode do the traitement and return the result
return view('calc')->with('res',$res) ;
the application work but the problem is that everytime i clic en send from the form calc/calc is added to the URL for Exemple :
First operation url is http://localhost/calcul/public/calc/calc
second operation url is http://localhost/calcul/public/calc/calc/calc
third operation http://localhost/calcul/public/calc/calc/calc/calc
What is the problem and how could i fix it
thnks
<form method="POST" action="calc/calc">
That action is calling a relative path, so it will always add an extra /calc on the end of each URL.
To stay on the same URL you can use:
<form method="POST" action="/calc/calc">
Additionally, you may want to use the laravel URL helper function to keep it nicer and future proof: