diff options
Diffstat (limited to 'app/Http/Controllers/GuestbookController.php')
-rw-r--r-- | app/Http/Controllers/GuestbookController.php | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/Http/Controllers/GuestbookController.php b/app/Http/Controllers/GuestbookController.php new file mode 100644 index 0000000..aff30ed --- /dev/null +++ b/app/Http/Controllers/GuestbookController.php @@ -0,0 +1,29 @@ +<?php + +namespace App\Http\Controllers; + +use Illuminate\Http\Request; +use DB; + +class GuestbookController extends Controller { + public function guestbook() { + return view('pages.guestbook'); + } + + public function guestbookPost(Request $request) { + $this->validate($request, [ + 'name' => 'required', + 'message' => 'required' + ]); + + DB::insert('INSERT INTO guestbook_entries (name, timestamp, ip_address, agent, message) values (?, ?, ?, ?, ?)', array( + htmlspecialchars($request->get('name')), + time(), + $request->ip(), + $request->userAgent(), + htmlspecialchars($request->get('message')) + )); + + return back()->with('success', 'Entry submitted successfully!'); + } +} |