1

I have a problem in Laravel 5 which happened with many people lot of times. So I debug my code already with all the solutions I can find on internet but in vein. Please look at my code.

View file:

@section('content')


<form method="post" action="/yurt/save_reservation_data" enctype="multipart/form-data">
<input type="hidden" name="_token" value="<?php echo csrf_token(); ?>" />
  <table align="center">

    <tr>
    <td colspan="3"><b>Credit Card Details</b></td>
    </tr>


    <tr>

                                        <td colspan="3">

                                            Credit Card #<br /> 

                                            <input type="text" id="ccNumber" name="ccNumber" class="required field" required="required" style="float:left;" value="">
                                            <img src="{{ URL::asset('img/creditcards.png') }}" alt="" width="100" />

                                        </td>

                                    </tr>

                                    <tr>

                                        <td colspan="3">

                                            Expiration<br /> 

                                            Month <select name="exp_m" id="exp_m" style="width:80px;" class="required field">
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
                                            Year <select name="exp_y" id="exp_y" style="width:120px;" class="required field">

<option value="17">2017</option>
<option value="18">2018</option>
<option value="19">2019</option>
<option value="20">2020</option>
<option value="21">2021</option>
<option value="22">2022</option>
<option value="23">2023</option>
<option value="24">2024</option>
<option value="25">2025</option>
<option value="26">2026</option>
<option value="27">2027</option>
<option value="28">2028</option>
<option value="29">2029</option>
<option value="30">2030</option>
</select>
                                        </td>

                                    </tr>

                                    <tr>

                                        <td colspan="3">

                                            CVV # <br /> 

                                            <input type="text" id="ccCVV" name="ccCVV" size="10" required="required" class="required field" value="">

                                        </td>

                                    </tr>

                                    <tr>

                        <td colspan="3">

                        <input type="checkbox" name="readTnC" value="1"  >

                        I have read and agree to the <a onclick="popopen();"  href="javascript:void(0);">Terms & Conditions</a> and <a onclick="popopen2();"  href="javascript:void(0);">Privacy Policy</a> of Hinsdale Haute Route<br /><br />

                        </td>

                    </tr>

                <tr>

                    <td colspan="3">

                        <input type="submit" class="btnRegisterGuestConfirm" value="Checkout" id="btnSubmit" name="checkout_submit" />          


<input type="hidden" name="firstname" value="{{$firstname}}" />
         <input type="hidden" name="lastname" value="{{$lastname}}" />
         <input type="hidden" name="adults" value="{{$adults}}" />
         <input type="hidden" name="children" value="{{$children}}" />
         <input type="hidden" name="property_id" value="{{$property_id}}" />
         <input type="hidden" name="address1" value="{{$address1}}" />
         <input type="hidden" name="address2" value="{{$address2}}" />
         <input type="hidden" name="city" value="{{$city}}" />
         <input type="hidden" name="state" value="{{$state}}" />
         <input type="hidden" name="zip" value="{{$zip}}" />
         <input type="hidden" name="phone" value="{{$phone}}" />
         <input type="hidden" name="cell" value="{{$cell}}" />
         <input type="hidden" name="email" value="{{$email}}" />
         <input type="hidden" name="sub_total_amount" value="{{$subtotaltext1}}" />
         <input type="hidden" name="lodging_amount" value="{{$lodging_amount}}" />
         <input type="hidden" name="date_start" value="{{$date_start}}" />
         <input type="hidden" name="date_end" value="{{$date_end}}" />
         <input type="hidden" name="total_amount" value="{{$totalamount}}" />
         <input type="hidden" name="sherpa_service" value="{{$sherpa_serv}}" />
         <input type="hidden" name="status" value="B" />
                            </td>

                </tr>

    <tr>
      <td colspan="3">
      </td>
    </tr>
  </table>
 </form>
</div>

                </div>
            </div>
        </div>


@stop

Route:

Route::post('save_reservation_data','FrontController@SubmitData');

Controller:

namespace App\Http\Controllers;

use App\Http\Requests;
use App\Http\Controllers\Controller;

use Illuminate\Http\Request;

use DB;

use Illuminate\Support\Facades\Mail;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Session;
use Oureastudios\Laravel\BraintreeServiceProvider;

class FrontController extends Controller {

public function SubmitData(Request $request)
    {

       // code where I am getting requestes from from

       $firstname   =   $request->input('firstname');
       $lastname    =   $request->input('lastname');
}

}

When I click on submit button in my form I get this error. I know you guys seen this issue many times but I have applied all solutions and cant get this issue resolved.

Any help will be appreciated.

Zain Abid
  • 129
  • 2
  • 13

2 Answers2

0

The form action should be:

action="/save_reservation_data"
Alexey Mezenin
  • 158,981
  • 26
  • 290
  • 279
  • Hi Alexey, actually I have path of this website is domainname.com and I put the code in "yurt" folder so I have to put the url in the action attribute like this "/yurt/save_reservation_data". All other pages of my website using are working like this except this form. I have other forms too on the website and they are working fine except this – Zain Abid Apr 26 '17 at 07:16
  • Also if I remove /yurt I get 404 – Zain Abid Apr 26 '17 at 07:18
  • @ZainAbid this means you're using wrong web server configuration. Read this http://stackoverflow.com/questions/37507209/how-to-hide-config-files-from-direct-access – Alexey Mezenin Apr 26 '17 at 07:21
  • Well Alexey, I have setup my project like this "/path_to_laravel_project/public" already – Zain Abid Apr 26 '17 at 07:29
0

Mismatched route

In route

Route::post('save_reservation_data','FrontController@SubmitData');
            ^^^^^^^^^^^^^^^^^^^^^^^ 

In form action

 action="/save_reservation_data" 
JYoThI
  • 11,977
  • 1
  • 11
  • 26
  • Hi JYoThI, actually I have path of this website is domainname.com and I put the code in "yurt" folder so I have to put the url in the action attribute like this "/yurt/save_reservation_data". All other pages of my website using are working like this except this form. I have other forms too on the website and they are working fine except this – Zain Abid Apr 26 '17 at 07:16
  • Also if I remove /yurt I get 404 – Zain Abid Apr 26 '17 at 07:18
  • change your root like this Route::post('/yurt/save_reservation_data','FrontController@SubmitData'); and action="/yurt/save_reservation_data" try this – JYoThI Apr 26 '17 at 07:24
  • when I do this, I get the error again. MethodNotAllowedHttpException RouteCollection.php line 207 – Zain Abid Apr 26 '17 at 07:26
  • did you setup your document root like this DocumentRoot "/path_to_laravel_project/public" – JYoThI Apr 26 '17 at 07:26
  • FYI, I am using 3 forms 1st post form on step 1, it is another view file and also another route and controller, then 2nd post form on step 2 another view file and another route and controller, but when I redirected to 3rd form and then click submit on 3rd post form I get this error, Is it happening due to consecutive POST form ? – Zain Abid Apr 26 '17 at 07:27
  • Yes I setup my document root like this "/path_to_laravel_project/public" – Zain Abid Apr 26 '17 at 07:28
  • check your third form method is post or get – JYoThI Apr 26 '17 at 07:29
  • the 3rd form method is post – Zain Abid Apr 26 '17 at 07:30
  • I tried to use patch there and also get but no vien, and get same error – Zain Abid Apr 26 '17 at 07:31
  • clear the cache usigng following commands php artisan route:clear php artisan cache:clear and then try – JYoThI Apr 26 '17 at 07:32
  • Clear the cache but same error, those are my routes for 3 form Route::post('step2','FrontController@step2'); Route::post('checkoutscreen','FrontController@Checkout_Screen'); Route::post('save_reservation_data','FrontController@SubmitData'); What I have doubt using 3 form consectively. and also when 1st form submitted it redirected the page to 2nd form and then when 2nd form completed it redirected the page to 3rd form with FORM data. is there any issue in this whole scenario ? – Zain Abid Apr 26 '17 at 07:36
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/142694/discussion-between-jyothi-and-zain-abid). – JYoThI Apr 26 '17 at 07:37