PHP SOLUTIONS: (Cheapest web hosting) DYNAMIC WEB DESIGN MADE EASY Using

PHP SOLUTIONS: DYNAMIC WEB DESIGN MADE EASY Using PHP to identify the current page I ll have more to say about security issues surrounding include files later in the chapter. First, let s fix that problem with the menu style that indicates which page you re on. PHP Solution 4-3: Automatically setting a style to indicate the current page Continue working with the same files. Alternatively, use index02.php, contact.php, gallery.php, journal.php, includes/menu.inc01.php, and includes/footer.inc01.php from the download files for this chapter. If using the download files, remove the 01 and 02 from any filenames. 1. Open menu.inc.php. The code currently looks like this:

The style to indicate the current page is controlled by the id=”here” highlighted in line 3. What you need is a way of getting PHP to insert id=”here” into the journal.php tag if the current page is journal.php, into the gallery.php tag if the page is gallery.php, and into the contact.php tag if the page is contact.php. Hopefully, you have got the hint by now you need an if statement (see the section on conditional statements, Making decisions, in Chapter 3) in each tag. Line 3 needs to look like this:

  • >Home
  • The other links should be amended in a similar way. But how does $currentPage get its value? You need some way of finding out the filename of the current page. 2. Leave menu.inc.php to one side for the moment and create a new PHP page called scriptname.php. Insert the following code between a pair of PHP tags (alternatively, just use scriptname1.php in the download files for this chapter): echo $_SERVER[’SCRIPT_NAME’]; 3. Save scriptname.php and view it in a browser. On a Windows system, you should see something like the following screenshot. (The download file contains the code for this step and the next, together with text indicating which is which.)
    Go visit our java server pages services for a reliable, lowcost webhost to satisfy all your needs.

    Leave a Reply