Users expect the dynamic effect that black icon can represent after clicking corresponding icon.
So then how to realize it by php?
<li><a <?php if(basename($_SERVER['SCRIPT_FILENAME'])=='father_module.php'){echo 'class="current"';}?> href="father_module.php">Father Module List</a></li>
In order to solve the problem, we can use if statement to judge whether the current page is the page which user click or not.
But It how do we get the php file name of current page. PHP provide $_GET to help us get acquire the current page url
and also provide basename() to help us extract the current php file name. At last, add the style to the Menu bar
which meet the condition.
When user click the menu bar, the title in browser also should be change to the corresponding name of menu bar.
So then how to realize it?
The father_module.php and father_module_add.php use the common header.php.
We can store the title name in a array, and assign the different name element to different page title.
Certainly, the definition of the variable should be did before the header.php which was included in the homepage.
In front-end page, we often use link to import css or js file, sometimes the css files are troublesome
to import, so then how to import css or js file more easily by PHP?
The solution method is similar with the problem of represent title name in browser.
We can store all the css file paths in a array and assign it to the same array.
Next step, foreach them in the header.php.
How to add a father module into database without errors appear, such as input restriction,
input type and avoid repeated module name was created?
The data can be transferred from input box to father_module_add.php by the method of $_GET,
and then use SQL statement to store the data in database. In a general way, the module name and
sort value should not be empty, so we should make a judgement on users’ information of input box after
they submitted it. The length restriction of module name and numeric type of number also should be set,
otherwise error would appear.In order to make special chars like quotation mark can be stored in database ,
the data which was received from users need to be escaped before stored in database.
In order to avoid that the repeated module name be created, we need to use
SQL statement select * from js_father_module where module_name='{$_POST['module_name']}' to
query whether exist the same module name already in database.