Free web servers - if (mysql_num_rows($result)) { echo n ; while ($row =
if (mysql_num_rows($result)) { echo
n . nl2br(htmlspecialchars($row[ comment ])) . n
n ; } Again, notice the use of htmlspecialchars() and nl2br() in the preceding code. Get used to using them; they are very important for converting text entered in a text box into readable text on an HTML page. The date function is quite powerful. It allows you to take the standard date value entered in a datetime field in MySQL and format it in many ways. In this case, the datetime of 2003-09-19 17:39:24 will be displayed as Friday September 19, 2003 17:39. Many options are available for displaying dates. For more information about this, visit www.php.net/date. The outputFunctions.php file is included on each page that needs one of its functions. If you have any other functions that you might want to add to your application, simply add it to this file, and make sure this file is included in the page. header.php Two additional files are included on every page that displays information on the Web: header.php and footer.php. Let s look at header.php now. (We won t look at footer.php, which should be self-explanatory.) This is the very first line of your page, and a very important one. Login information is stored using sessions. As you might remember from previous chapters, sessions allow you to store values to be used elsewhere on the site. This makes sessions ideal for storing login data. By using session_start() at the beginning of your page, you are telling the application to allow you access to $_SESSION variables. Now you can set and retrieve session variables. For a more detailed discussion of sessions, visit www.php.net/session. Here s the first example of session variables. Once session_start() has been initialized, the variable $_SESSION[ name ] should be available to you, as long as the user has logged in. So, if isset($_SESSION[ name ]) returns FALSE, you know the user is not logged in. 429 Building a Content Management System
From our experience, we can recommend PHP Web Hosting services, if you need affordable webhost to host and run your web application.