Home   Help Login Register  
Welcome, Guest. Please login or register.

Login with username, password and session length

Search
Free Website WooThemes - Quality Themes, Great Support
Pages: [1]   Go Down
Print
Topic: Using PHP and MySQL to Develop a Simple CMS - Version 2  (Read 1299 times)
« on: August 30, 2007, 01:21:40 PM »
Tech Offline
Newbie

View Profile
*

iTrader: 1
Posts: 183



In version 1 of our simple CMS we introduced the following four files:

    * cms.sql
    * updatePage.htm
    * updatePage.php, and
    * index.php

      Together, these files formed a very simple CMS, which you can download from the following address:

      http://www.computernostalgia.net/downloads/cms_v1.zip

      In this article we'll extend the CMS slightly so that the database contents are extracted and presented in the form (UpdatePage.htm). This will make it easier to edit the contents, rather than simply overwriting them.

      In order to make this modification, updatePage.htm needs to become a PHP file. I've called it editPage.php because updatePage.php already exists.

      Here is the contents of editPage.php:

      1. < html >
      2. < head >
      3. < title >Really Simple CMS< /title >
      4. < /head >
      5. < body >
      6. < h1 >Really Simple CMS< /h1 >
      7. < ?php
      8. mysql_connect("localhost", "root", "password");
      9. $result = @mysql_query("SELECT contents from cms.page");
      10. while ($row = mysql_fetch_assoc($result)){
      11. $contents = $row['contents'];
      12. }
      13. ? >
      14. < form name="form1" method="post" action="updatePage.php" >
      15. Enter page content:< br >< textarea rows="10" cols="60" name="contents" >< ?php echo "$contents" ? >< /textarea >


      16. < input type="submit" name="Submit" value="Update Page" >
      17. < /form >
      18. < /body >
      19. < /html >

Most of this file is fairly simple HTML that doesn't need explaining. However, the following bits of code are probably worth discussing.

Lines 7 through to 13 containt PHP code to connect to the database and extract the contents of the web page.

Line 15 contains a tiny bit of PHP code to display the contents in the form's textarea. This line shows how easy it is to integrate bits of PHP code into lines of HTML code.

Remember though that in order to use PHP code in an HTML page, the file has to have an extension of .php.

All of the files for version 2 of the CMS are available at:

http://www.computernostalgia.net/downloads/cms_v2.zip

Article Source: http://EzineArticles.com/?expert=John_Dixon

Share this topic on AskShare this topic on BlinkbitsShare this topic on BlinklistShare this topic on BloglinesShare this topic on BmarksShare this topic on Del.icio.usShare this topic on DiggShare this topic on DzoneShare this topic on FacebookShare this topic on Feed Me LinksShare this topic on FurlShare this topic on GoogleShare this topic on LiveShare this topic on MagnoliaShare this topic on MySpaceShare this topic on NetvouzShare this topic on NewsvineShare this topic on OneviewShare this topic on RedditShare this topic on RojoShare this topic on ScuttleShare this topic on ShadowsShare this topic on SlashdotShare this topic on SpurlShare this topic on SquidooShare this topic on StumbleUponShare this topic on TechnoratiShare this topic on TwitterShare this topic on TipdShare this topic on YahooShare this topic on Google buzz
« Last Edit: December 31, 1969, 05:00:00 PM by Tech » Logged

Pages: [1]   Go Up
Print
Jump to:  

Untitled Document
(c) 2012 HELM, WHM, cPanel, ASP, .Net development, PHP, MySQL, MSSQL Server, SEO support forum
Powered by SMF 1.1.16 | SMF © 2011, Simple Machines | Forum style designed by PixelSlot
Google - Sitemap - XML Sitemap