aboutsummaryrefslogtreecommitdiff
path: root/app/Http/Controllers/GuestbookController.php
blob: aff30ed3a6c3900cae38162c0f75ec6210b4b744 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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!');
    }
}