0
I developed a website in Laravel
that presents a problem in the form because it simply does not work and displays no error on the screen it simply has no action and the strange thing is that localhost
the site works for example has an error code that when the user tries to submit the form without filling in the fields displays an error on the localhost
it appears already in the lodging it has no action I took a look at the log
and also exhibits nothing else anyway follows the log
with my code.
Error sending form without filling in fields (localhost
)
Errors do not appear in the hosting
:
Website address: http://agenciafront.com.br/aldeia/
Form:
@if (count($errors) > 0)
<div class="alert alert-danger">
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
@if (session('message'))
<div class="alert alert-success">
{!! session('message') !!}
</div>
@endif
{!! Form::open(array('action' => 'FormController@postContato', 'role' => 'form', 'class'=>'form')) !!}
<div class="form-group">
<div class="row">
<div class="col-md-6">
{!! Form::text('nome', null, array('placeholder'=>'Nome')) !!}
{!! Form::text('email', null, array('placeholder'=>'E-mail')) !!}
{!! Form::text('telefone', null, array('placeholder'=>'Telefone')) !!}
</div>
<div class="col-md-6">
{!! Form::textarea('mensagem', null, array('placeholder'=>'Mensagem', 'rows'=>'5')) !!}
{!! Form::submit('Enviar', array('class' => 'btn btn-success'), array('id' => 'btn_submit')) !!}
</div>
</div>
</div>
{!! Form::close() !!}
Formcontroller:
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Validator;
use Mail;
use App\Http\Requests;
class FormController extends Controller
{
public function index() {
return view('/');
}
public function postContato(Request $request) {
$rules = array( 'nome' => 'required', 'email' => 'required|email', 'telefone' => 'required', 'mensagem' => 'required' );
$errors = [
'required' => 'O campo :attribute é obrigatório.',
'email' => 'Digite um email válido.',
];
$validation = Validator::make($request->all(), $rules, $errors);
$data = array();
$data['nome'] = $request->input("nome");
$data['email'] = $request->input("email");
$data['telefone'] = $request->input("telefone");
$data['mensagem'] = $request->input("mensagem");
if($validation->passes()) {
Mail::send('emails.contato', $data, function($message) use($request){
$message->from($request->input("email"), $request->input("nome"));
$message->to('[email protected]') ->subject('contato do site');
$message->bcc('[email protected]') ->subject('Contato do site');
});
return redirect('#contato')->with('message', 'Mensagem enviada com sucesso!');
}
return redirect('#contato')->withErrors($validation);
}
}
Route:
<?php
Route::get('/', function () {
return view('welcome');
})->name('home');
Route::get('coworking',[
'as' => 'coworking',
'uses' => 'CoworkingController@index'
]);
Route::get('evento',[
'as' => 'evento',
'uses' => 'EventoController@index'
]);
Route::get('sobre',[
'as' => 'sobre',
'uses' => 'SobreController@index'
]);
Route::get('criancas',[
'as' => 'criancas',
'uses' => 'CriancasController@index'
]);
/*Route::get('contato',[
'as' => 'contato',
'uses' => 'ContatoController@index'
]);*/
Route::post('/', 'FormController@postContato');
The site seems to me to be set wrong, already begins by the route
/
that it is very strange to submit information like this!,view('/')
It’s kind of strange also the page call, at the time you are sending the information should be clashing with other routes! How many routes are in your route file?– novic
@Virgilionovic thanks for the reply friend I will update the question and I will put all the routes I have so far are not many
– Felipe Henrique
@Virgilionovic tá la amigo all the routes I have in this project I added in the question
– Felipe Henrique
has a subtle difference in localhost and the web, I don’t know if you noticed! that intereffects on the route. localhost is doing right, already the web has an additional address that is the reason why (
aldeia
), don’t notice errors because the site is not redirected correctly...– novic
@Virgilionovic No friend I did not realize this difference what you recommend me to do ?
– Felipe Henrique
@Kirito enables debug in production.
– Kayo Bruno
@Kirito you should put in the domain really and test for it, if you are testing inside another folder this is the problem of the routes, example:
http://agenciafront.com.br/
so it’s right, and so it’s wronghttp://agenciafront.com.br/aldeia
, road problems– novic
The next thing is that this site server is also a test server to go up the site to the original domain that would be www.aldeia.com.br for example so all the time we do a new project we put this site in this domain that would be agenciafront.om.br/village
– Felipe Henrique
Oh Laravel doesn’t work properly @Kirito got it? that is the reason, put it right in the domain and do the test, if locally worked, on the web will also work ... Apparently your site has no problem, although there is redundant and unnecessary code.
– novic
Got it buddy I’m gonna give it to you
– Felipe Henrique