Archive for March, 2008

Ipower web hosting - if ($article) { echo n ; } else {

Monday, March 31st, 2008

if ($article) { echo n ; } else { echo n ; } And so it ends, footer and all. Clean and simple. ?>

If you ve looked around your Web site, you might have noticed that the article you just created doesn t show up yet. That s because you ve set up a review system wherein an administrator or moderator must approve an article before it is published to the public view. This sort of control is found on many CMSbased sites on the Web and is a good way to keep an eye on quality and duplicate stories. Try It Out Reviewing New Articles In this exercise, you ll create the reviewing system that lets you approve your articles. 1. Create pending.php: submitted , Published => published ); echo

Article Availability

n ; $i = -1; foreach ($a_artTypes as $k => $v) { $i++; echo

. $k . Articles

n ; echo

n ; echo

n ; $sql = SELECT article_id, title, date_ . $v . FROM cms_articles . WHERE is_published= . $i . ORDER BY title ; $result = mysql_query($sql, $conn) or die( Could not get list of pending articles; . mysql_error()); if (mysql_num_rows($result) == 0) { echo No . $k . articles available ; } else { while ($row = mysql_fetch_array($result)) { 462 Chapter 13
Note: If you are looking for cheap and reliable webhost to host and run your mysql application check mysql web server services.

Web design programs - WHERE article_id= . $_GET[ article ]; $result = mysql_query($sql, $conn)

Sunday, March 30th, 2008

WHERE article_id= . $_GET[ article ]; $result = mysql_query($sql, $conn) or die( Could not retrieve article data; . mysql_error()); $row = mysql_fetch_array($result); $title = $row[ title ]; $body = $row[ body ]; $article = $_GET[ article ]; $authorid = $row[ author_id ]; } Load the prerequisite header.php: require_once header.php ; What follows is more standard HTML stuff. You know what htmlspecialchars() does, don t you? Of course you do. If not, go back a page or two and review. ?>

Compose Article

Title:
>

Body:

The article ID must be carried over to the transaction page if you are modifying an existing article. The following hidden input field will do this for you. n ; You also need to pass the author ID if the original author is editing his or her own document. if ($_SESSION[ access_lvl ] < 2) { echo n ; } If the article is being modified, display the Save Changes submit button. If it s a new article, display the Submit New Article button. 461 Building a Content Management System
Please visit Domain Name Hosting services for high quality webhost to host and run your jsp applications.

Figure 13-7 How It Works You re almost there. (Web host)

Saturday, March 29th, 2008

Figure 13-7 How It Works You re almost there. Next, you tackle compose.php, the page where you create new articles. First, initialize the variables you are going to be using: If you are looking for affordable and reliable webhost to host and run your business application visit our ftp web hosting services.

$title = $row[ title ]; $body = $row[ body ]; $article = (Web site development)

Friday, March 28th, 2008

$title = $row[ title ]; $body = $row[ body ]; $article = $_GET[ article ]; $authorid = $row[ author_id ]; } require_once header.php ; ?>

Compose Article

Title:
>

Body:

n ; if ($_SESSION[ access_lvl ] < 2) { echo n ; } if ($article) { echo n ; } else { echo n ; } ?>

2. Click the Compose link to load compose.php (see Figure 13-7). 3. Enter a title and some text for the article. When you are done, click Submit New Article. You will be taken back to the index page, but there will still be no article. The article you just wrote is pending review. 459 Building a Content Management System
We recommend high quality webhost to host and run your jsp application: christian web host services.

Web space - First you display the page title: ?> User

Thursday, March 27th, 2008

First you display the page title: ?>

User Administration

Then you loop through the code three times, running the function each time with a different level value:

. $a_users[$i] .

n .

n ; echoUserList($i); echo n

n ; } ?> And then you re done.
Article Publishing You have all these transaction pages and user account maintenance so far, but nothing that would put your application squarely into the CMS category. Well that s all about to change! In this section you ll be creating the pages that allow you to create, review, read, and comment on articles. On to the articles! Try It Out Creating an Article In your first step toward having content, you re going to create the page that allows you to actually write out the articles and save them to the database. 1. Create a new file and name it compose.php: We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.

Ecommerce web host - Hey, a function. Shouldn t this go in an

Wednesday, March 26th, 2008

Hey, a function. Shouldn t this go in an include file, such as outputfunctions.php? Perhaps, and you could certainly do that if you wanted to. However, this function is very specific to this file, so it really doesn t need to go in an include file. It s up to you, really. function echoUserList($lvl) { To use the array you created earlier within this function, you must declare it global. Now the function can access the data in the array. global $a_users; This function will be called more than once. Each time, a different value will be contained in the $lvl variable. The following SQL pulls the appropriate data according to the $lvl value: $sql = SELECT user_id, name, email FROM cms_users . WHERE access_lvl = $lvl ORDER BY name ; $result = mysql_query($sql) or die(mysql_error()); If no users are found in the database for this access level, you display a message explaining that those users were not found. You do this by using the array you created earlier: if (mysql_num_rows($result) == 0) { echo No . $a_users[$lvl] . created. ; Auser cannot modify his or her own record. Instead, his or her name is shown in plain text, with no link. } else { while ($row = mysql_fetch_array($result)) { if ($row[ user_id ] == $_SESSION[ user_id ]) { echo htmlspecialchars($row[ name ]) .
n ; Otherwise, the user s name is displayed on the screen, as a link that loads useraccount.php. } else { echo . htmlspecialchars($row[ name ]) .
n ; } Here s the end of the function. Note that nothing has been output to the screen yet. } } } 457 Building a Content Management System
If you are looking for cheap and quality webhost to host and run your website check Jboss Web Hosting services.

Http web server - Figure 13-6 How It Works Guess what? You

Tuesday, March 25th, 2008

Figure 13-6 How It Works Guess what? You guessed it. Our good friends conn.php and header.php are back. Okay, let s move on. Users , Moderators , Admins ); 456 Chapter 13
In case you need quality webspace to host and run your web applications, try our personal web hosting services.

Web hosting contract - echoUserList($i); echo nn ; } ?> 2. Go ahead

Monday, March 24th, 2008

echoUserList($i); echo n

n ; } ?>
2. Go ahead and log out, and then log back in using your admin account. When you are logged in, click the Admin link. You should see a screen similar to Figure 13-5. You should see George Smith (or whatever name you used) under Users. You will notice your Admin name under Admins, but it is not a link. You can alter your own account from your Control Panel. Figure 13-5 3. Click the user listed under Users. You should see a page similar to that in Figure 13-6. Notice that you can change the user s name and password. Also notice the Access Level option. You can set any user to be a User, Moderator, or Admin. User is the default for new users. 455 Building a Content Management System
You want to have a cheap webhost for your apache application, then check apache web hosting services.

And there is your footer page again, closing (Web hosting uk)

Sunday, March 23rd, 2008

And there is your footer page again, closing things off neatly: User Management You may be wondering, How does the administrator create other administrators or moderators to help manage the site? Well, now we re going to give you the scripts to do just that. Try It Out Administration Page In this exercise, you ll create the pages necessary for administrators to manage the site. 1. Create admin.php: Users , Moderators , Admins ); function echoUserList($lvl) { global $a_users; $sql = SELECT user_id, name, email FROM cms_users . WHERE access_lvl = $lvl ORDER BY name ; $result = mysql_query($sql) or die(mysql_error()); if (mysql_num_rows($result) == 0) { echo No . $a_users[$lvl] . created. ; } else { while ($row = mysql_fetch_array($result)) { if ($row[ user_id ] == $_SESSION[ user_id ]) { echo htmlspecialchars($row[ name ]) .
n ; } else { echo . htmlspecialchars($row[ name ]) .
n ; } } } } ?>

User Administration

. $a_users[$i] .

n .

n ; 454 Chapter 13
Check Tomcat Web Hosting services for best quality webspace to host your web application.

Then cycle through each one, displaying them as (Web hosting service)

Saturday, March 22nd, 2008

Then cycle through each one, displaying them as radio buttons on the page. while ($row = mysql_fetch_array($result)) { echo . $row[ access_name ] .
n ; } The next page requires the user ID. Because this is not entered in a form field, create a hidden field to carry the data over to the transaction page. ?>

>

A short but sweet PHP tag ends the first part of the if statement and adds an else clause. This is a very flexible way of using if…else commands with standard HTML. Because you can enter and exit PHP at any time, your pages are very flexible and easy to read. The rest of this code is loaded if you are not an admin type. If you are not an admin, you must be here to create a new account. Therefore, it asks you for your password:

Password:

Password (again):

Then comes the end of the if statement and the end of the form:

453 Building a Content Management System
Visit our web design programs services for an affordable and reliable webhost to suit all your needs.