feat: add guestbook with rate limiting (#6)
* Re-add guestbook w/ rate limiting * Add guestbook to navbar
This commit is contained in:
parent
8adae46775
commit
94133ec0f7
12 changed files with 329 additions and 91 deletions
29
app/Http/Controllers/GuestbookController.php
Normal file
29
app/Http/Controllers/GuestbookController.php
Normal file
|
@ -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!');
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue