Skip to content

Instantly share code, notes, and snippets.

@Fendo181
Last active November 3, 2016 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Fendo181/354fb883487b0671e8f0cba7b9462c10 to your computer and use it in GitHub Desktop.
Save Fendo181/354fb883487b0671e8f0cba7b9462c10 to your computer and use it in GitHub Desktop.
laravelで問い合わせフォーム チュートリアル
@extends('layouts.master')
@section('title', '確認画面')
@section('content')
<div class="body">
<div class="top">
<h3>確認画面です!</h3>
</div>
<form action="{{ url('/complete')}}" method="post">
<table border="1" align="center">
<tr>
<th>氏名</th>
<td><b>{{ $name }}</b></td>
</tr>
<tr>
<th>性別</th>
<td><b>{{ $gender }}</b></td>
</tr>
<tr>
<th>お問い合わせ内容</th>
<td><b>{{ $question }}</b></td>
</tr>
</table>
<div class="top">
<input type = "submit" value =この内容で完了画面へ進む。>
</div>
</form>
<div class="top">
<a href="{{ url('/contact') }}" >Back Home</a>
</div>
</div>
@stop
<?php
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use App\Http\Requests;
class ContactController extends Controller
{
//
public function top()
{
return view('contact.top');
}
public function check(Request $request){
$name = $request->input('name');
$gender = $request->input('gender');
$question = $request->input('question');
//方法1 普通
// return view('contact.check')->with('name',"$name")
// ->with('gender',"$gender")
// ->with('question',"$question");
// 方法2 配列 良さ気
return view('contact.check')->with([
'name'=>"$name",
'gender'=>"$gender",
'question'=>"$question"
]);
}
}
<!-- Stored in resources/views/layouts/master.blade.php -->
<html>
<head>
<title>@yield('title')</title>
<link rel="stylesheet" href="css/mystyle.css">
</head>
<body>
<!-- @section('sidebar')
This is the master sidebar.
@show -->
<div class="container">
@yield('content')
</div>
</body>
</html>
/*共通*/
.body{
color: #333;
font-size: 1.2rem;
font-family: "Hiragino Kaku Gtothic ProN",Meiryo,sans-serif;
}
.top{
text-align: center;
}
<?php
/*
|--------------------------------------------------------------------------
| アプリケーションのルート
|--------------------------------------------------------------------------
|
| ここでアプリケーションのルートを全て登録することが可能です。
| 簡単です。ただ、Laravelへ対応するURIと、そのURIがリクエスト
| されたときに呼び出されるコントローラーを指定してください。
|
*/
/*
ルーティングは下の方から優先される。
*/
Route::get('/', function () {
return view('welcome');
});
Route::get('contanct','ContactController@top');
Route::post('check','ContactController@check');
//phpninfo
// Route::get('/php',function(){
// return phpinfo();
// });
//
//
//
// // //who の練習コード
// // Route::get('who',function(){
// // return 'Hello!'.Request::input('name','welcome!');
// // });
// //
// // Route::get('who/{name}',function($name){
// // return 'Hellow'.$name.'!! welcome Laravel5!';
// // });
//
//
//
//
// //JSの勉強用
// Route::get('/js','BaseController@index');
@extends('layouts.master')
@section('title', '問い合わせ画面')
@section('content')
<div class="body">
<div class="top">
<h3>お問い合わせ画面です!</h3>
</div>
<form action="{{ url('/check')}}" method="post">
{!! csrf_field() !!}
<table border="1" align="center">
<tr>
<th>氏名</th>
<td><input type="text" name="name" placeholder="氏名を入力して下さい。"></td>
</tr>
<tr>
<th>性別</th>
<td><label for="male"><input type="radio" name="gender" id="male" value="男性">男性</label>
<label for="female"><input type="radio" name="gender" id="female" value="女性">女性</label>
<label for="other"><input type="radio" name="gender" id="other" value="回答しない">回答しない</label>
</td>
</tr>
<tr>
<th>お問い合わせ内容</th>
<td>
<textarea name="question" cols="40" rows="3" placeholder="ご遠慮無く不満を教えて下さい"></textarea>
</td>
</tr>
</table>
<div class="top">
<input type = "submit" value =この内容で確認する。>
</div>
</form>
</div>
@stop
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment