Archive for February, 2008

Figure 13-3 How It Works Let s look at (Make web site)

Wednesday, February 27th, 2008

Figure 13-3 How It Works Let s look at index.php. Include the standard files: We recommend high quality webhost to host and run your jsp application: christian web host services.

Make my own web site - 4. Load index.php in your browser. 5. Click

Tuesday, February 26th, 2008

4. Load index.php in your browser. 5. Click the Login link on the page, or open login.php in your browser. Enter the e-mail address and password you previously stored in the database, and click the Login button (see Figure 13-2). Don t remember the login/password combination? Try admin@yoursite.com for the e-mail address, and admin for the password. You should now see a simple screen similar to Figure 13-3. There is not much to see yet, because you haven t written any articles. You should, however, see a handful of menu options. Figure 13-2 446 Chapter 13
From our experience, we are can tell you that you can find a reliable and cheap webhost service at Java Web Hosting services.

2. Next, create forgotpass.php: Email Password Reminder Forgot (Domain and web hosting)

Monday, February 25th, 2008

2. Next, create forgotpass.php:

Email Password Reminder

Forgot your password? Just enter your email address, and we ll email your password to you!

Email Address:

3. Create index.php: n ; echo There are currently no articles to view.n ; } else { while ($row = mysql_fetch_array($result)) { outputStory($row[ article_id ], TRUE); } } require_once footer.php ; ?> 445 Building a Content Management System
Looking for affordable and reliable webhost to host and run your business application? Then look no more and go to servlet web hosting services.

Web design conference - And again, if a user has somehow loaded

Sunday, February 24th, 2008

And again, if a user has somehow loaded this page without any posted variables, he or she is immediately redirected to the home page. } else { redirect( index.php ); } User Interface So you ve created your transaction pages, and your reusable functions, but haven t yet actually seen any real on-screen functionality. Well now s your chance! In this section, we re going to be creating the scripts that make up the various user interface screens. Dust off your browser, and let s get started! General Functionality The first group of files you ll be dealing with are going to provide general user access to the site. Scripts similar to these are found on many sites across the Internet, so you ll probably be familiar with their functionality. Try It Out Main Index/Login Screen The first scripts you re going to create will deal with the action of a user coming to the site, logging in, requesting aide due to a forgotten password, and new account creation. 1. Create login.php:

Member Login

Email Address:

Password:

Not a member yet? Create a new account!

Forgot your password?

444 Chapter 13
Note: In case you are looking for affordable and reliable webhost to host and run your j2ee application check Vision J2ee Web Hosting services.

redirect( pending.php ); break; If the article ID was passed, (Apache web server for windows)

Saturday, February 23rd, 2008

redirect( pending.php ); break; If the article ID was passed, and the comment field is filled in, process this transaction. case Submit Comment : if (isset($_POST[ article ]) and $_POST[ article ] and isset($_POST[ comment ]) and $_POST[ comment ]) { Insert the article ID, the comment date (in MySQL datetime format), the user ID, and the actual comment into the database. When this has been accomplished, redirect the user to the article so he or she can see the newly saved comment. $sql = INSERT INTO cms_comments . (article_id,comment_date,comment_user,comment) . VALUES ( . $_POST[ article ] . , . date( Y-m-d H:i:s ,time()) . , . $_SESSION[ user_id ] . , . $_POST[ comment ] . ) ; mysql_query($sql, $conn) or die( Could add comment; . mysql_error()); } redirect( viewarticle.php?article= . $_POST[ article ]); break; This is a case where the action is passed in the URL (?action=remove&article=123). Verify that the article ID was passed and that the user is logged in. case remove : if (isset($_GET[ article ]) and isset($_SESSION[ user_id ])) { You currently allow only users to delete their own articles. You might modify this transaction to allow moderators and admins to delete any article, but for now only users can delete the articles they have written. $sql = DELETE FROM cms_articles . WHERE article_id= . $_GET[ article ] . AND author_id= . $_SESSION[ user_id ]; mysql_query($sql, $conn) or die( Could not remove article; . mysql_error()); } redirect( cpanel.php ); break; Once again, don t forget to close your switch statement: } 443 Building a Content Management System
If you are searching for cheap webhost for your web application, please visit MySQL5 Web Hosting services.

Web hosting billing - if (isset($_POST[ authorid ])) { redirect( cpanel.php ); } else { redirect( pending.php );

Friday, February 22nd, 2008

if (isset($_POST[ authorid ])) { redirect( cpanel.php ); } else { redirect( pending.php ); } break; Next you make sure the article ID was passed. If it was, modify the article in the database to set the is_published column to 1, and set the date_published datetime column to the current date and time (formatted in MySQL datetime format). case Publish : if ($_POST[ article ]) { $sql = UPDATE cms_articles . SET is_published=1, date_published= . date( Y-m-d H:i:s ,time()) . . WHERE article_id= . $_POST[ article ]; mysql_query($sql, $conn) or die( Could not publish article; . mysql_error()); } redirect( pending.php ); break; This next case is actually quite similar to the Publish case, only this time, after checking the article ID, you set is_published to 0 and erase the date_published field. Retracting an article in this case simply returns it to its pre-published state, but you might think of better ways to retract an article. Perhaps you could have separate columns for is_retracted and retract_date. There is no right or wrong way to do it, and, of course, it depends on the needs of your own site. case Retract : if ($_POST[ article ]) { $sql = UPDATE cms_articles . SET is_published=0, date_published= . WHERE article_id= . $_POST[ article ]; mysql_query($sql, $conn) or die( Could not retract article; . mysql_error()); } redirect( pending.php ); break; Check to see that an article ID was passed, and simply delete the record. case Delete : if ($_POST[ article ]) { $sql = DELETE FROM cms_articles . WHERE is_published=0 . AND article_id= . $_POST[ article ]; mysql_query($sql, $conn) or die( Could not delete article; . mysql_error()); } 442 Chapter 13
You want to have a cheap webhost for your apache application, then check apache web hosting services.

datetime to be displayed on the Web, you (Photoshop web design)

Thursday, February 21st, 2008

datetime to be displayed on the Web, you can format it any way that you want. The standard datetime format for September 21, 2003, 12:42 a.m. is 2003-09-21 00:42:00. $sql = INSERT INTO cms_articles . (title,body, author_id, date_submitted) . VALUES ( . $_POST[ title ] . , . $_POST[ body ] . , . $_SESSION[ user_id ] . , . date( Y-m-d H:i:s ,time()) . ) ; mysql_query($sql, $conn) or die( Could not submit article; . mysql_error()); } redirect( index.php ); break; The Edit case is simple. The compose.php page is set up to retrieve an article and preload it into the title and body fields if the appropriate data is entered in the URL. You simply need to add a=edit and article=xx to the URL and redirect the user to that URL. case Edit : redirect( compose.php?a=edit&article= . $_POST[ article ]); break; Make sure the title and body fields have been filled in, and that the hidden field article contains a value. If you were composing a new document, the hidden field would not contain anything, and you d know something was wrong. (You can t use the Save Changes feature for a new document.) case Save Changes : if (isset($_POST[ title ]) and isset($_POST[ body ]) and isset($_POST[ article ])) { Next you send the article to the database. If the hidden field authorid has a value, then a user is editing her or his own document, and you must add the condition to match the author_id to the SQL statement. $sql = UPDATE cms_articles . SET title= . $_POST[ title ] . , body= . $_POST[ body ] . , date_submitted= . date( Y-m-d H:i:s , time()) . . WHERE article_id= . $_POST[ article ]; if (isset($_POST[ authorid ])) { $sql .= AND author_id= . $_POST[ authorid ]; } mysql_query($sql, $conn) or die( Could not update article; . mysql_error()); } You then redirect the user to either the control panel, if the user is editing his or her own document, or the review page, if the user is a moderator or admin editing someone else s document. 441 Building a Content Management System
In case you need affordable webhost to host your website, our recommendation is ecommerce web host services.

mysql_query($sql, $conn) or die( Could not remove article; (Web server version)

Wednesday, February 20th, 2008

mysql_query($sql, $conn) or die( Could not remove article; . mysql_error()); } redirect( cpanel.php ); break; } } else { redirect( index.php ); } ?> How It Works Want to look at some more code? Great! Let s take a look at transact-article.php. This time, we ll simply point out some of the more interesting things we might not have covered yet, or things that bear repeating. Yes, this bears repeating. You know what the following does, right? It registers the session variables that invariably will need to be set in order to run some of these transactions. This gives you access to the data for the currently logged-in user: session_start(); The transact-article.php page requires connection to the database, and redirects users to various pages using the redirect() function. The following two include files provide this functionality, respectively. require_once conn.php ; require_once http.php ; You need to make sure that a button was pressed, or an action is specified in the URL (such as ?action= twiddleThumbs). if (isset($_REQUEST[ action ])) { A lot of actions can happen in this file. The switch() statement is a more elegant way of choosing your transactions than if/else. switch ($_REQUEST[ action ]) { You first ensure that the title and body were both entered and that the user is logged in (tested by the presence of the user_id session variable). case Submit New Article : if (isset($_POST[ title ]) and isset($_POST[ body ]) and isset($_SESSION[ user_id ])) { You insert the article into the database, including the user ID and the date. The datetime is formatted in a standard MySQL datetime format that can be stored in a datetime column. When you retrieve that 440 Chapter 13
Searching for affordable and proven webhost to host and run your servlet applications? Go to Linux Web Hosting services and you will find it.

WHERE article_id= . $_POST[ article ]; mysql_query($sql, $conn) (Web site hosting) or die( Could

Tuesday, February 19th, 2008

WHERE article_id= . $_POST[ article ]; mysql_query($sql, $conn) or die( Could not publish article; . mysql_error()); } redirect( pending.php ); break; case Retract : if ($_POST[ article ]) { $sql = UPDATE cms_articles . SET is_published=0, date_published= . WHERE article_id= . $_POST[ article ]; mysql_query($sql, $conn) or die( Could not retract article; . mysql_error()); } redirect( pending.php ); break; case Delete : if ($_POST[ article ]) { $sql = DELETE FROM cms_articles . WHERE is_published=0 . AND article_id= . $_POST[ article ]; mysql_query($sql, $conn) or die( Could not delete article; . mysql_error()); } redirect( pending.php ); break; case Submit Comment : if (isset($_POST[ article ]) and $_POST[ article ] and isset($_POST[ comment ]) and $_POST[ comment ]) { $sql = INSERT INTO cms_comments . (article_id,comment_date,comment_user,comment) . VALUES ( . $_POST[ article ] . , . date( Y-m-d H:i:s , time()) . , . $_SESSION[ user_id ] . , . $_POST[ comment ] . ) ; mysql_query($sql, $conn) or die( Could add comment; . mysql_error()); } redirect( viewarticle.php?article= . $_POST[ article ]); break; case remove : if (isset($_GET[ article ]) and isset($_SESSION[ user_id ])) { $sql = DELETE FROM cms_articles . WHERE article_id= . $_GET[ article ] . AND author_id= . $_SESSION[ user_id ]; 439 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.

if (isset($_REQUEST[ action ])) { switch ($_REQUEST[ action ]) { case Submit (Web hosting isp)

Monday, February 18th, 2008

if (isset($_REQUEST[ action ])) { switch ($_REQUEST[ action ]) { case Submit New Article : if (isset($_POST[ title ]) and isset($_POST[ body ]) and isset($_SESSION[ user_id ])) { $sql = INSERT INTO cms_articles . (title,body, author_id, date_submitted) . VALUES ( . $_POST[ title ] . , . $_POST[ body ] . , . $_SESSION[ user_id ] . , . date( Y-m-d H:i:s , time()) . ) ; mysql_query($sql, $conn) or die( Could not submit article; . mysql_error()); } redirect( index.php ); break; case Edit : redirect( compose.php?a=edit&article= . $_POST[ article ]); break; case Save Changes : if (isset($_POST[ title ]) and isset($_POST[ body ]) and isset($_POST[ article ])) { $sql = UPDATE cms_articles . SET title= . $_POST[ title ] . , body= . $_POST[ body ] . , date_submitted= . date( Y-m-d H:i:s , time()) . . WHERE article_id= . $_POST[ article ]; if (isset($_POST[ authorid ])) { $sql .= AND author_id= . $_POST[ authorid ]; } mysql_query($sql, $conn) or die( Could not update article; . mysql_error()); } if (isset($_POST[ authorid ])) { redirect( cpanel.php ); } else { redirect( pending.php ); } break; case Publish : if ($_POST[ article ]) { $sql = UPDATE cms_articles . SET is_published=1, date_published= . date( Y-m-d H:i:s ,time()) . . 438 Chapter 13
We highly recommend you visit web and email hosting services if you need stable and cheap web hosting platform for your web applications.