File tree Expand file tree Collapse file tree
user_guide_src/source/tutorial Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ the slug from our title in the model. Create a new view at
3333
3434 <h2><?= esc($title) ?></h2>
3535
36+ <?= session()->getFlashdata('error') ?>
3637 <?= service('validation')->listErrors() ?>
3738
3839 <form action="/news/create" method="post">
@@ -47,10 +48,15 @@ the slug from our title in the model. Create a new view at
4748 <input type="submit" name="submit" value="Create news item" />
4849 </form>
4950
50- There are probably only two things here that look unfamiliar. The
51- ``service('validation')->listErrors() `` function is used to report
52- errors related to form validation. The ``csrf_field() `` function creates
53- a hidden input with a CSRF token that helps protect against some common attacks.
51+ There are probably only three things here that look unfamiliar.
52+
53+ The ``<?= session()->getFlashdata('error') ?> `` function is used to report
54+ errors related to CSRF protection.
55+
56+ The ``service('validation')->listErrors() `` function is used to report
57+ errors related to form validation.
58+
59+ The ``csrf_field() `` function creates a hidden input with a CSRF token that helps protect against some common attacks.
5460
5561Go back to your ``News `` controller. You're going to do two things here,
5662check whether the form was submitted and whether the submitted data
Original file line number Diff line number Diff line change 3939
4040 namespace App\Controllers;
4141
42- use CodeIgniter\Controller;
43-
44- class Pages extends Controller
42+ class Pages extends BaseController
4543 {
4644 public function index()
4745 {
@@ -66,7 +64,7 @@ displays the CodeIgniter welcome page.
6664 Both are *technically * a function. But when you create a function in a class,
6765 it's called a method.
6866
69- The ``Pages `` class is extending the
67+ The ``Pages `` class is extending the `` BaseController `` class that extends the
7068``CodeIgniter\Controller `` class. This means that the new Pages class can access the
7169methods and variables defined in the ``CodeIgniter\Controller `` class
7270(**system/Controller.php **).
You can’t perform that action at this time.
0 commit comments