Arkadaslar yeni-yeni konu acmayip buradakini editledim.
Kendimce bir form yaptim kodlari asagidaki gibi yanlislarim soyler misiniz ?
Tesekkurler
routes.php
Route::get('contact/create',
['as' => 'contact/create',
'uses' => 'ContactController@create']);
Route::post('contact/save',
['as' => 'contact/save',
'uses' => 'ContactController@save']);
Route::get('contact/succesfull',
['as' => 'contact/succesfull',
'uses' => 'ContactController@succesfull']);
ContactController.php
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
class ContactController extends Controller
{
public function create()
{
return view ('registration/register');
}
public function save(Request $request)
{
$this->validate($request, [
'txtSurname' => 'required',
'txtName' => 'required',
'txtPhone' => 'required',
]);
return view('registration/succesfull');
}
public function succesfull()
{
return view('registration/succesfull');
}
}
registration/register.blade.php
<!DOCTYPE html>
<html>
<head>
<title>Laravel</title>
<link href="https://fonts.googleapis.com/css?family=Raleway:100" rel="stylesheet">
<style type="text/css">
html
{
background:#333;
}
form
{
background:#fff;
width:320px;
border: 1px solid #ccc;
padding: 10px;
display:table;
}
form h4
{
font-family: 'Raleway', sans-serif;
font-size:14pt;
margin:0px;
}
form hr
{
margin:0px;
border: 1px solid #ccc;
}
.line
{
font-family: 'Raleway', sans-serif;
width: 320px;
padding: 10px 0px;
display:block;
}
.line label
{
width:100px;
display: block;
float:left;
}
.line input[type=text]
{
width:210px;
border: 1px solid #ccc;
}
.line input[type=reset],input[type=submit]
{
font-family: 'Raleway', sans-serif;
border: 1px solid #ccc;
padding:5px;
}
.line label[class="error"]
{
width: 300px;
color:red;
}
</style>
</head>
<body>
<form method="post" action="{{ url('contact/save') }}">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
<div class="line">
<h4>Add new contact</h4>
</div>
<div class="line">
<hr/>
</div>
<div class="line">
<label class="error">{{ $errors->first('txtSurname') }}</label>
<label for="txtSurname"> Surname :</label>
<input type="text" name="txtSurname" value="{{ old('txtSurname') }}" />
</div>
<div class="line">
<label class="error">{{ $errors->first('txtName') }}</label>
<label for="txtName"> Name :</label>
<input type="text" name="txtName" value="{{ old('txtName') }}"/>
</div>
<div class="line">
<label class="error">{{ $errors->first('txtPhone') }}</label>
<label for="txtPhone"> Phone :</label>
<input type="text" name="txtPhone" value="{{ old('txtPhone') }}"/>
</div>
<div class="line">
<input type="reset" name="btnReset" value="Clear">
<input type="submit" name="btnSubmit" value="Save">
</div>
</form>
</body>
</html>
registration/succesfull.blade.php
<!DOCTYPE html>
<html>
<head>
<title>Laravel</title>
<link href="https://fonts.googleapis.com/css?family=Raleway:100" rel="stylesheet">
<style type="text/css">
html
{
background:#333;
}
.message
{
background:#fff;
font-family: 'Raleway', sans-serif;
width: 320px;
padding: 10px;
display:block;
}
</style>
</head>
<body>
<div class="message"">
Succesfully saved
</div>
</body>
</html>