Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ecw_szilard97's avatar

Store function won't work

Hello. I have a form what is working well on localhost but on server don't access the store function from Controller.

Form:

       {!! Form::open(['method' => 'POST', 'action' => 'HomePageController@store', 'class' => 'appointment-form']) !!}
               ...
                        <div class="pull-right">
                            {!! Form::submit('Submit', ['class' => 'btn btn-default pull-right']) !!}
                        </div>
       {!! Form::close() !!}

Controller:

 /**
     * Store a newly created resource in storage.
     *
     * @param  \Illuminate\Http\Request  $request
     * @return \Illuminate\Http\Response
     */
    public function store(Request $request)
    { 
	   $input = $request->all();
        dd($input);

        if (Auth::check()) {

        ...

            if (env('MAIL_USERNAME') == '' && env('MAIL_PASSWORD') == '') {
                return back()->with('added', 'Sikeresn rögzitettük az időpont foglalást!');
            }

            $data = array(
                'name' => $user_name,
                'email' => $user_email,
                'washing_plan' => $washing_plan,
                'vehicle_company' => $vehicle_company,
                'vehicle_modal' => $vehicle_modal,
                'vehicle_type' => $vehicle_type,
                'date' => $appointment_date,
                'time_frame' => $time_frame,
            );

            Mail::send('emails.home_appointment_emails', compact('data'), function ($message) use ($data) {
                $message->from(env('MAIL_USERNAME'));
                $message->to($data['email']);
                $message->subject('Időpont foglalás');
            });

            Mail::send('emails.home_appointment_emails', compact('data'), function ($message) use ($data) {
                $message->to(env('MAIL_USERNAME'));
                $message->subject('Új időpont foglalás');
            });

            return back()->with('added', 'Sikeresn rögzitettük az időpont foglalást!');

        } 

    }

Route:

Route::resource('/', 'HomePageController');

Auth::routes();

After submition the form will don"t store the information on database but is refreshing the page. The interesting thing is that I still have a another form on this website that is working properly.

0 likes
19 replies
Snapey's avatar

you won't find many here willing to help with that forms library

Sinnbeck's avatar

Never use env outside of config files. It will return null in production

if (env('MAIL_USERNAME') == '' && env('MAIL_PASSWORD') == '') {

Use the config versions

config('mai.mailers.smtp.username')
1 like
Sinnbeck's avatar

Check the page to see which url it is trying to post to in the form (F12 -> Elements)

ecw_szilard97's avatar

Okey. Thanks i solved it. It was a / on url. Why its not recomanded to use the env file ?

Sinnbeck's avatar

@ecw_szilard97 That looks really bloken. That is why we dont use that form package

<form action="/" method="post" class="appointment-form" />
ecw_szilard97's avatar

@Sinnbeck but if i define on this way how he will know i make reference on store function. Because on route i have defined it with resource

Sinnbeck's avatar

@ecw_szilard97 You can do the same

<form action="{{ action([HomePageController::class, 'store']) }}" method="post" class="appointment-form" />
ecw_szilard97's avatar

@Sinnbeck but the result isn't it the same as mine? Sorry, I don't want to sound rude, its just new to me and that's why I'm asking.

ecw_szilard97's avatar

@Sinnbeck

{!! Form::open(['method' => 'POST', 'action' => 'HomePageController@store', 'class' => 'appointment-form']) !!}

this

<form action="{{ action([HomePageController::class, 'store']) }}" method="post" class="appointment-form" />

ecw_szilard97's avatar

like it seems he is getting the action link from a config file. I tought it was from env file but no.

Sinnbeck's avatar

@ecw_szilard97 My point was to drop that package and just write html.. Or wait for someone to come along that uses it and can help with it :)

1 like

Please or to participate in this conversation.