Making Your Form Fields POP
Reader Level:
Make your forms POP by using a little CSS and a little jQuery. A nice background animated effect, similar to what Wufoo does on their forms, all wrapped up and easy to use for anyone!
Connecting the Real World to Your Web Site Using QR Codes
Reader Level:
The rise of smart phones, and the "always-connected" attitude that has accompanied them, means that the web is being stretched and positioned into far more parts of our daily lives. One interesting aspect of this omnipresence is the concept of hardlinking, a term used to describe technologies or techniques used to link real world objects to websites or digital presence.
The technology is actually quite simple: create an image (similiar to a barcode) that users can point their camera-equipped smart phones at, have the device do some recognition and direct the user to the appropriate web site, contact information, or any other data you want!
In today's article we're going to explore one of the most common techniques for hardlinking: QR codes. We'll look at what they are, briefly talk about how they work, and look at how we can generate them using PHP.
The Quick and Easy Way to Get Your PHP Server Set Up to Send Emails
Reader Level:
The ability to send emails from PHP scripts is something that many developers take for granted; what happens though when you make the move from hosted accounts to your own servers though and find that the same email scripts you've been using for years no longer work? The problem lies not in your code but in the fact that PHP uses another underlying program called sendmail to actually send emails out, and if that isn't set up or configured properly then your email scripts will never work!
In this article we're going to take a look at a very quick and easy way to get your own PHP server processing and sending out emails without all the headaches of a full sendmail configuration thanks to a little program called sSMTP. We'll even look at how you can use it in conjunction with Gmail to get emails up and running in less than 10 minutes!
Passively Tracking the Number of Online Users Through PHP Sessions
Reader Level:
The ability to display the number of users who are currently on your website at any given time can be a big boost for both advertisers and end users. On the web, after all, popularity plays a major role in success. Today we're going to look at one of the easiest and also most efficient methods of gathering and presenting this "realtime information": PHP session counting.
Increase SEO with Keyword-Driven URLs For Content Management Systems CMS Using PHP and CodeIgniter
Reader Level:
A common approach to
Search Engine Optimization (SEO) is to provide the search engine context for the content of your page with keywords in the URL. This strategy is so prevalent that most major blogs and content management systems (CMS) feature a
'clean URL' or
URL rewrite feature. The rewrite feature looks at the structure of the page link and deciphers it into the content identification needed to bring up the designated content from the database. By using keywords relevant to your site in page URLs instead of relatively meaning code numbers, your site can achieve better ranking for those keywords. For example, which URL below will be better understood to search engines and humans?
http://wordpress.org/index.php?p=6427302910
or
http://wordpress.org/news/2010/07/wordpress-3-0-1/
The way many blog and CMS apps operate their url rewrite system is to give the content editor a field to write a URL title. This can work well, but in my years of building custom CMS apps for businesses I have that the
content editors are often challenged with copywriting skills. Recently, I've taken a different tack with URL titles by automatically using the title of the content for the link. I figure that if the linked content piece is relevant enough to be added to the site,
the title should already have relevant keywords.
In this tutorial, I will show you several
methods for creating keyword-driven URLs for content management systems using PHP. Then we will explore the methods of deciphering the content links with both CodeIgniter and Apache mod_rewrite.
Ordering Checkbox Look-ups in PHP
Reader Level:
After learning how to manage checkbox look-ups in PHP, as subscriber decided to take the process a step further and allow users to specify a custom order to the look-ups. This tutorial will show you how to add an ordering field to the look-up table, dynamically process the ordering form element and display the look-up results with the custom order. We will also work with dynamically-created array and variable names as well as variable variable names to access data. Let's move on the next steps!
Using PHP cURL and simple_html_dom When There is No RSS Feed
Reader Level:
One of the original purposes of the net was to give people the ability to quickly and effectively share information with others. The widespread adoption of technologies like RSS have greatly enhanced the level of automation that we, as developers, can employ in bringing data from other sites to our own. However, there are still many occasions when, for whatever reason, the information you want to display on your own site is not provided by any kind of feed mechanism. While many developers may either revert to manual updates or write it off as impossible all together, the fact is that with a bit of creative thinking you can incorporate data from virtually any web site into your own (assuming you're not violating their copyrights or privacy policies of course!).
Today we're going to see how a few PHP techniques can be combined to create a fairly easy to implement "HTML crawler" to automatically parse data from another site and make it available for your own.
Working with Images in PHP - Part 3: Scaling
Reader Level:
The ability to directly alter image files from PHP scripting is one of those interesting skills that most web developers are not even aware of. While this technology has been around for a few years now, the advent of more advanced client-side coding means that a combination of server and client-side technologies can now be used to create very interesting and effective online image manipulation tools.
Imagine an online photo gallery where users can upload images, and then rotate and crop them in realtime from their browser. Why not just use Photoshop? Well just remember that because you're dealing with a browser based solution your users gain the ability to do all this from their smart phones or other mobile devices that may not have image manipulation applications like Photoshop. In other words you're giving your users the ability to completely "cut out" the need for a full-blown computer for yet another important aspect of their social online experience!
The goal of this series will be to show you, step by step, how to build that realtime web-based image editing application. In the first few parts of the series we're going to focus on the basic PHP image manipulation code that we'll need to actually modify the graphic files; then later we'll see how to tie those in with jQuery and some client-side coding to create our application. Today we're going to talk about how to perform image scaling using GD and PHP.
The Working with Images in PHP Series:
Working with Images in PHP - Part 1: Rotation
Working with Images in PHP - Part 2: Cropping
Working with Images in PHP - Part 3: Scaling
File-Based Error Logging in PHP
Reader Level:
Normally, I debug PHP scripts by
echoing diagnostic content to the screen during the development of dynamic web sites. Recently, a client informed me that there seemed to be an intermittent bug in the checkout routine of a recently completed ecommerce site. Because the site had already gone live, my usual troubleshooting approach was inappropriate. Additionally, testing had to be completed on the live site to ensure functionality with live configuration and merchant account settings.
In order to capture and analyze diagnostic data while the site was live, I implemented a
file-based logging function which worked in the background. The function, described below, was created to be light-weight and flexible in order to minimize performance impacts and provide a wide range of information.
The file-based function was successful in identifying the failure point of the script leading to its fix. Further, the client decided to leave it turned on and collecting data in case further problems appeared during the site's initial rollout.
Working with Images in PHP - Part 2: Cropping
Reader Level:
The ability to directly alter image files from PHP scripting is one of those interesting skills that most web developers are not even aware of. While this technology has been around for a few years now, the advent of more advanced client-side coding means that a combination of server and client-side technologies can now be used to create very interesting and effective online image manipulation tools.
Imagine an online photo gallery where users can upload images, and then rotate and crop them in realtime from their browser. Why not just use Photoshop? Well just remember that because you're dealing with a browser based solution your users gain the ability to do all this from their smart phones or other mobile devices that may not have image manipulation applications like Photoshop. In other words you're giving your users the ability to completely "cut out" the need for a full-blown computer for yet another important aspect of their social online experience!
The goal of this series will be to show you, step by step, how to build that realtime web-based image editing application. In the first few parts of the series we're going to focus on the basic PHP image manipulation code that we'll need to actually modify the graphic files; then later we'll see how to tie those in with jQuery and some client-side coding to create our application. Today we're going to talk about how to perform image cropping using GD and PHP.
The Working with Images in PHP Series:
Working with Images in PHP - Part 1: Rotation
Working with Images in PHP - Part 2: Cropping
Working with Images in PHP - Part 3: Scaling
Log Your Logins with PHP and MySQL for Better Customer Service
Reader Level:
If you run a web site with user accounts, you are likely familiar with countless emails from users who claim they cannot log in to the site. While published CMS applications have password recovery tools, most don't give you a record of log in attempts. This tutorial will show you
how to add a log to your application which records failed or successful log in attempts from users (and even non-users.)
Using PHP and MySQL, this script will not only record log in attempts but other useful diagnostic
IP address
browser version
referrer address
All of this information helps you provide better customer service by better understanding your users and their usage habits. From this information, your can better determine:
- how often a specific user or users in general access your site
- when users access your site
- which pages on your site which are more likely to prompt users to log in
- which browser is used most often by active users
- potential account abuses due to password sharing
- potential security weaknesses due to brute force hacking attempts
- whether or not a specific user was able to log in
Working With Images in PHP - Part 1: Rotation
Reader Level:
The ability to directly alter image files from PHP scripting is one of those interesting skills that most web developers are not even aware of. While this technology has been around for a few years now, the advent of more advanced client-side coding means that a combination of server and client-side technologies can now be used to create very interesting and effective online image manipulation tools.
Imagine an online photo gallery where users can upload images, and then rotate and crop them in realtime from their browser. Why not just use Photoshop? Well just remember that because you're dealing with a browser based solution your users gain the ability to do all this from their smart phones or other mobile devices that may not have image manipulation applications like Photoshop. In other words you're giving your users the ability to completely "cut out" the need for a full-blown computer for yet another important aspect of their social online experience!
The goal of this series will be to show you, step by step, how to build that realtime web-based image editing application. In the first few parts of the series we're going to focus on the basic PHP image manipulation code that we'll need to actually modify the graphic files; then later we'll see how to tie those in with jQuery and some client-side coding to create our application. Today we're going to start by looking at how to load, rotate, and save an image in PHP.
The Working with Images in PHP Series:
Working with Images in PHP - Part 1: Rotation
Working with Images in PHP - Part 2: Cropping
Working with Images in PHP - Part 3: Scaling
Quickshot - Using Multiple Databases in PHP
Reader Level:
One of the most common misnomers about databases on the web is that you should only ever need a single database per project. If you're dealing with very time-sensitive and critical information in your database though it's often appropriate to have some form of realtime backup: this is called database replication.
Today we're going to look at one possible way of implementing this from within your PHP scripts by using replicant queries, a technique which involves issuing all of your queries to two different databases. This is one of the most direct cross-database replication methods and is actually a lot easier to implement than you'd expect!
Managing Checkbox Look-ups in PHP
Reader Level:
A common practice in CMS content management systems is to allow content to be applied to any number of categories or tags. On a recent project, I needed to create a CMS for articles which could be related to any number of sport categories. The web site editor needed to be able to select any number of related categories for a specific article and these settings were saved in a MySQL lookup table. With this table of many-to-many relationships, I was able to populate a list of category checkboxes for each article as well as to retrieve applicable articles when a specific category was viewed.
This tutorial will show how to create an HTML form with a checkbox for each category and dynamically load settings from a MySQL database. Then, we look at a script for saving the lookup settings. Finally, we'll see the resulting lookup table in action selecting articles which have been tagged to a specific category.
How to Report Non-Calendar Years in PHP and MySQL
Reader Level:
Calendar years make reporting easy. The calendar year 2010 is simply distinguished from 2009. What could be easier than selecting all records from the current calendar year?
SELECT * FROM `records` WHERE YEAR(`record_date`) = YEAR(NOW())
Some organizations, however, maintain reporting calendars which do not start on January 1 and end on December 31. Businesses maintain a
fiscal year, educational institutions keep an
academic year and even sports leagues keep
seasons which begin in one calendar year and end in the next. In these cases, assessing the current year is not as simple as looking at the calendar. For example, the fiscal year for many countries around the world begins July 1 and ends on the following June 30. The Government of the US has a fiscal year which starts on October 1. In the UK, the fiscal year for personal taxation reporting begins on April 6.
This article will show you how to use both PHP and MySQL to
define a custom reporting year and
determine the current reporting year at any date. These functions will allow you to easily include the start and end points of the year as well as create reporting queries based on these defined temporal end points.
A PHP CodeIgniter Library for Authorize.net Customer Information Manager (CIM)
Reader Level:
When a client chose to use Authorize.net's Customer Information Manager (CIM) for processing credit card payments from within their CodeIgniter-based web site, I went into research mode. Years ago, I programmed a shopping site which used Authorize.net's Advanced Integration Method (AIM) to directly submit credit card transaction requests directly to their server via delimited query string. That method required the submittal of all customer billing information for every transaction - especially since we kept no billing information on file for security - so I was impressed when I learned that CIM maintained a profile for each customer with multiple billing and shipping profiles each. The CIM method, released in November 2007, added the ability for a merchant to securely store customer billing data - including credit card numbers - on Authorize.net's servers.
The CIM API allows you to validate, create, retrieve, update and delete customer billing information with several types of profiles through XML requests. Each customer has a main Profile, and up to 10 Payment Profiles and up to 100 Shipping Profiles. The extent of these profiles allow a merchant to offer the customer the convenience of stored billing data with the security of Authorize.net's servers. The convenience and security will hopefully translate into repeat sales. The CIM Merchant Web Services API XML Guide provides some overview of the process but is mostly focused on the details of each type of request and filed parameters.
What was missing for me was an example of these requests as well as the actual process of submitting requests and processing their responses. Enter John Conde, a Certified Authorize.Net Developer, who in February 2010 published a PHP class for handling the CIM requests and responses. Even better, the tutorial on John's site showed me exactly what needed to happen. I downloaded a copy of his class, signed up for an Authorize.net developer account and got to work. Then I realized several hurdles to overcome.
What If MySQL Could Eliminate PHP?
Reader Level:
The hallmark of a successful programmer can be measured in economy of code. Being proficient means doing more work with less code. In working with MySQL data in PHP scripts, one can eliminate a lot of heavy lifting in PHP with some simple MySQL functions. In today's example, we'll look at MySQL's IF() function as a way to supply data already interpreted so we don't have to do the work in PHP.
PHP In-Depth: Not All Equal Statements Are Identical in Comparison
Reader Level:
PHP provides three forms of equality. Understanding the differences and uses of '=', '==' and '===' is vital to your success as a programmer. In this article we'll cover the differences and usages of each, as well as noting a few gotchas to avoid. While '==' will tell you if items are equal, the fact that PHP uses loose comparisons can lead to incorrect comparisons which in turn lead to faulty logical decisions. In this article we'll learn how to avoid this problem.
Audit a MySQL Data Table - Part 2
Reader Level:
When you have a database table that gets updated or changed, it makes sense to keep track of those updates. A relational database table is like a snapshot in time. It contains your data in its most recent form. When you update it, the previous data is lost. For example, a product might have a price. When you change that price, the previous price is lost. Many times it can be retrieved from a log, but another way to make sure you have an audit trail of your data is to create dedicated audit tables for each table that you want to keep track of.
This article will show one simple way to create an audit table and related functionality in MySQL without needing to modify your web application much at all. This first part of the series covered setting up the sample application and database table. This part will show the audit functionality and how to create it. For the article, I'll assume you know how to set up PHP sites, work with basic database operations in PHP (listing, inserting, updating data), and work with session variables. The series will focus on the auditing of the table.
The Audit a MySQL Data Table Series:Audit a MySQL Data Table - Part 1Audit a MySQL Data Table - Part 2Audit a MySQL Data Table - Part 3
Page Fragmentation Using SimpleHTMLDOM
Reader Level:
One of the biggest moves in content presentation and management over the last few years has been page fragmentation. That is, thanks to JavaScript and AJAX methods web developers have begun to change and update smaller parts of each page in real time, rather than reloading the entire thing whenever any time of interaction occurs. Perhaps one of the most difficult challenges of this type of approach though is determining how to actually divide up your page content and manage it on your web server so that you don't end up with hundreds of "tiny HTML page snippets" that are dynamically combined to form actual pages of a site.
Today we're going to look at a very clean and easy solution to this problem utilizing the Simple HTML Dom library for PHP.
Creating a Bar Graph with HTML and CSS using PHP - Part 2
Reader Level:
Graphs in web pages and reporting applications can be put together with various PHP libraries, such as using the JpGraph library shown in JpGraph: PHP Graphs & Charts On-The-Fly by Steven Seiller, or with JavaScript libraries that are widely available. However, sometimes you have a need for a simple bar graph that does not depend on this more advanced technology; working with PHP servers that do not have libraries installed, or targeting browsers that are not JavaScript enabled.
Bar graphs can be created quite easily using ancient HTML technology without the aid of more advanced techniques for simple bar graphs that display quickly and across all browsers. For this tutorial, I'll assume you know basic PHP and SQL -- writing queries, views, and getting the results you want.
A bar graph can be built vertically or horizontally. The first part showed the horizontal graph. This part will show the vertical graphing process. The basic process is to create the SQL query that you want to view the result as a graph, use a slim image that can be stretched as a basis of the bar graph, and set the height of the image based on the value of your data. For example, a value of $50 might translate to 50 pixels high, and $500 might translate to 500 pixels high. Using simple formulas, we'll create the graphs.
The Creating a Bar Graph with HTML and CSS Series:
Creating a Bar Graph with HTML and CSS using PHP - Part 1
Creating a Bar Graph with HTML and CSS using ColdFusion - Part 1
Creating a Bar Graph with HTML and CSS using PHP - Part 2
Creating a Bar Graph with HTML and CSS using ColdFusion - Part 2
Creating a Bar Graph with HTML and CSS using PHP Part 1
Reader Level:
Graphs in web pages and reporting applications can be put together with various PHP libraries, such as using the JpGraph library shown in JpGraph: PHP Graphs & Charts On-The-Fly by Steven Seiller, or with JavaScript libraries that are widely available. However, sometimes you have a need for a simple bar graph that does not depend on this more advanced technology; working with PHP servers that do not have libraries installed, or targeting browsers that are not JavaScript enabled. Bar graphs can be created quite easily using ancient HTML technology without the aid of more advanced techniques for simple bar graphs that display quickly and across all browsers. For this tutorial, I'll assume you know basic PHP and SQL -- writing queries, views, and getting the results you want.
A bar graph can be built vertically or horizontally. I'll show a simple horizontal graph in this part. The basic process is to create the SQL query that you want to view the result as a graph, use a slim image that can be stretched as a basis of the bar graph, and set the width of the image based on the value of your data. For example, a value of $50 might translate to 50 pixels wide, and $500 might translate to 500 pixels wide. Using simple formulas, we'll create the graphs.
The Creating a Bar Graph with HTML and CSS Series:
Creating a Bar Graph with HTML and CSS using PHP - Part 1
Creating a Bar Graph with HTML and CSS using ColdFusion - Part 1
Creating a Bar Graph with HTML and CSS using PHP - Part 2
Creating a Bar Graph with HTML and CSS using ColdFusion - Part 2
PHP 411: The phpinfo() Report
Reader Level:
PHP provides a convenient function, phpinfo(), which displays information regarding the PHP installation, configuration and operating environment of your server. Details include PHP version number, installed modules, predefined variables and server environment information. The provided information is very useful for the purposes of maintaining your PHP installation, verifying installed functionality, verifying server information and for troubleshooting your scripts.
If you are new PHP developer, this is definitely one function you'll need to integrate into your workflow to become an informed and proficient programmer.
This tutorial will give you a brief orientation to the phpinfo() function and give you some ideas of how you can use it to your advantage.
Private Directory Listing and File Serving with PHP
Reader Level:
Want to provide limited access on your site to directories and files? This script lists the contents of files and directories in private directories not normally accessible in a web browser. Using private directories to store and retrieve content gives you a controlled method of serving paying customers or workgroup partners.
This tutorial will discuss the concept of web scope and where to store files on your server so they cannot be accessed normally through a web browser. This protects the files from arbitrary downloads or hotlinking. Using the code previously published to provide directory and file listings, we will revise the process to allow browsing in a private directory. Because you cannot directly link to files outside of web scope, we'll also use PHP to fetch the contents of a requested file and feed it to the user through the browser.
Fancy Indexing Directory Listing with PHP
Reader Level:
This script lists the contents of files and directories in the
Apache Web Server. While Apache has built-in functionality to list files and directories with the
FancyIndexing directive, the functionality is limited and the icons are outdated.
This script lists the contents of any
directory or
sub-directory into which the script is placed for the purpose of browsing, viewing or saving files. It features
contextual icons for file types and only list files and directories found within the structure of the script's directory. You can even add your own
style sheet to the listings.
It is possible to directly alter the Apache configuration to display listings with your preferred style, but you need root access to the underlying levels of the Web server and advanced knowledge of the configuration. If you have root access, you can also simply change the default icons provided with Apache which is limited in terms of file types. Since many developers do not have root access to their Web server nor wish to muck about in the configuration,
this script provides an easy alternative to customizing directory listings.
This tutorial will demonstrate how to use this
directory listing script and show you the one line of code which (possibly) needs to be customized for your Web server. You will also be shown how you can customize the script to incorporate your site design, data display and how to implement the configuration on a site-wide basis. Advanced and developing PHP programmers can also explore the functionality of:
- reading directories of files
- reading file attributes including date, extension, and size
- sorting arrays
- formatting the file size to human readable display
- working with server path and links
PHPMailer-ML - Mailing List Manager and eMessage Manager
Reader Level:
PHPMailer-ML is a mailing list and newsletter management tool. It leverages the easy-to-use and powerful PHPMailer package from an online administrative center that you run on your own web server. You can use PHPMailer-ML to receive subscription requests from your website and to manage your mailing list. From PHPMailer-ML you can send emails to your mailing lists in HTML or plain text format. The administrative center allows you to create mailing campaigns, select mailing lists and create e-mails. Like PHPMailer, PHPMailer-ML is distributed for free under the General Public License (GPL). This tutorial will show you how to install and use the basic features of PHPMailer-ML.
PHPMailer-ML was originally developed to showcase the function of PHPMailer in 2008. During 2009 the project has received significant development in terms of interface, CSV import function and newsletter editing. PHPMailer is a popular, top-rated PHP class for simplifying the sending of plain text e-mail, HTML e-mail and attachments.
PHP Is Losing Its Magic-Get Used to It Now
Reader Level:
The use of Magic Quotes in your PHP scripts has long been shown to be an insecure method of security. While this function is currently in the process of being deprecated, it will finally be removed as a PHP 6. Make your transition process easier by taking the time now to assess your reliance on the Magic Quotes directive and revise your scripts if needed.
PHP Sledgehammer: array_map
Reader Level:
In PHP you have an array of data that you wish to transform with a function. You might be tempted to create a control structure and loop through each value of the array, applying the function as you go. PHP has an easier method for accomplishing this process. It is the sledgehammer known as array_map. I find this function useful, for example, to trim the whitespace from incoming form data.
PHP Undo Delete Button in Dreamweaver
Reader Level:
For those of us with Gmail accounts, we have seen, after deleting an email, the undo link show up on the page. Sometimes that is a real savior for me! Of course, it is also nice that I don't have to confirm each delete that I do. I looked in to a simple way to have an undo button on my delete functionality for database tables. With a few quick steps, we can make this work for you as well.
Creating a Form Confirmation Page in PHP
Reader Level:
A confirmation page is the last page you reach before submitting a form -- you fill in the fields, click submit, review your information, and then submit one final time. Confirmation pages can be built in different ways. I'll show one method, using PHP, that utilizes hidden form fields to post to your final action page. I'll leave the bells and whistles to the reader (validation, CSS, etc.) and show the meat of the technique that is being used.
JpGraph: PHP Graphs & Charts On-The-Fly
Reader Level:
JpGraph is an object-oriented PHP library for creating graphs on the fly with your selected data for display on web pages. The library features a wide range of graph types with which you can draw with your own data. You can supply data from a database, a text file, a form or even with a GET query string.
Generating web-based graphs for display on web pages can be useful for business intelligence or marketing collateral. The advantage of creating a graph dynamically from data is that the visitor always sees an up-to-date chart which reflects current data.
This tutorial will briefly give you an overview of the installation procedure and how to create several graphs, including the source code. The JpGraph library is easy to use, features a wide range of customization options as well as many graph types.
Sending Email from PHP in Windows
Reader Level:
One of the most commonly used features of PHP is the mail function (or some class built around it). This handy command allows you to send emails from within your PHP code, providing a wide variety of handy features ranging from client notifications to administrative reminders. However, if you're working on a Windows-based testing server you'll often find that that mail functionality simply doesn't work!
In this article we're going to look at why this is and two easy ways to help remedy the problem.
PHP Output Buffer: The Programmer's Assistant
Reader Level:
PHP's Output Buffering has many useful applications and should be in the toolbox of any advanced PHP coder. In short, PHP can save the output of content to the browser in a temporary buffer until called to use it. Buffering output has many applications inlcuding:
- Sending headers such as a cookie after beginning to process a page.
- Output at once the contents of a dynamically-built page.
- Capturing page content until the script determines where the content will be used.
- Capture and re-routing script errors instead of displaying to visitor.
- Redirecting page output to a log file or email body.
- Conducting string replacement on page content to provide custom mark-up or vocabulary.
- Dynamically building images with PHP.
- Compressing page output to provide a faster download to the visitor.
- Using show/hide logic for verbose content.
Select Random Content with PHP and MySQL
Reader Level:
You want to provide random content from your database to visitors of your web page. This might include random news, products, events or testimonials. How do you select random content from your MySQL database? During the visitor's time on your web page, you wish to not repeat the display of the same content. How do you not repeat the same random content?
In this tutorial, we will use PHP and MySQL to randomly pick and display content to the visitor. For extra credit, we will track the content the user has already been shown and not repeat it. We will also look at a way to further customize the chosen content.
Creating an Alphabetical Directory Listing with PHP and MySQL
Reader Level:
You want to create an alphabetic listing of database records by grouping them by their first letter. As a convenience, you want to provide a menu of alphabet letters with hyperlinks to take you directly to the records for that letter. How do you create an alphabetic listing of database records without performing 26 queries - one for each letter?
I've reduced the process to just one query which first selects the first letter represented by the records and then grabs the data itself. I created arrays for each letter to store data until it is displayed. The script uses a few advanced PHP bits to keep the code concise including:
- MySQL substring() function
- range() function
- array_key_exists() function
- ternary operator
- variable variables
Easy Dates With PHP DateTime Class
Reader Level:
PHP version 5.2.0 expanded its date handling capabilities with a new class and procedural methods. With pre-defined formats, outputting dates requires less arcane formatting knowledge. The new DateTime Class adds to PHP's object-oriented collection of functionality, although not fully implemented. This article will introduce you to these new features which should give you more direct approaches to formatting and outputting dates and times. The attached demonstration file shows all of the formats in action.
Heredoc and Nowdoc: PHP Strings of Convenience
Reader Level:
In PHP, strings are created in one of two fashions: exactly as stated or by including the value of variables which have been placed in the string. PHP offers to syntax methods for creating longer strings: heredoc and nowdoc. This article will demonstrate the syntax for these methods and provides some examples for their use.
Conditional PHP: Using the Ternary Operator
Reader Level:
There are many uses for conditional statements in programming. The basic principle of conditional programming is that you want to execute code based on a certain condition. The essence of conditional programming is executing code based on the condition being true, with an alternate piece of code being executed if the condition is not true. The article will explain the ternary operator, which creates if/else logic that is more concise than other methods.
Creating a Formatted Unique ID in PHP
Reader Level:
There are often times that you need a unique id in an application, but don't want to use an auto-incrementing integer. If an application is well designed and secure, an auto-incrementing number is usually fine, but to be on the safe side a unique identifier other than an integer is better as an id. For example, a customer number is a good use of a unique identifier, or an order number.
Blank Pages in PHP
Reader Level:
If you are a PHP developer, you are likely familiar with the blank page -- an error page with no error message. PHP has some default settings that prevent any error messages from appearing when you install PHP and do not adjust the error display settings. This article will show how to show your error messages.
Creating MySQL Logins for a Web Site
Reader Level:
MySQL is a popular database to use for your web site, allowing the power of a server-based database management system to be used for free. With the added power comes added danger—MySQL is frequently targeted by hackers. My article on
preventing SQL injection attacks mentioned database login security briefly.
In this article, I will expand on how to actually create users for your web site, which is vital knowledge when you are acting as a database administrator. If you have a PHP site using MySQL and you don't have a database administrator—you are it.
Processing Submitted HTML Form Data - Part 2: PHP
Reader Level:
This tutorial will walk through the essentials of processing submitted HTML form data. Whether you are processing information submitted through a contact form, a blog or a content management system, you must understand the essential components of submitted form data in order to process the submitted information. You might process the submitted data with ASP, ColdFusion, PHP or Perl but regardless of the scripting language you choose, the data submitted through the Common Gateway Interface (CGI) remains the same.
In Part 1 of this tutorial, we reviewed the CGI process and the two methods of submitting form data via HTML. Additionally, we will look at the range of form controls at your disposal and the nature of the data returned by each control. In Part 2 of this tutorial, I will use PHP to demonstrate the structure and values of typical form data with sample processing routines.
The Processing Submitted HTML Form Data Series:
Processing Submitted HTML Form Data - Part 1
Processing Submitted HTML Form Data - Part 2: PHP
Add, Edit and Delete Records with PHP and Dreamweaver - Video
Reader Level:
Dreamweaver comes with some really great wizards which make the add/edit/delete process for database tables quick work. This tutorial will walk you through creating all of the needed functionality to get this done.
Approximate download size: 17MB
Dynamically Streaming a File in PHP
Reader Level:
There are many ways to create a file download from a web site, however, sometimes it is necessary to hide the physical path of the file. In PHP it is possible to dynamically stream the file to the end user, eliminating the chance that a user can download the file directly. This is often a requirement of an e-store that sells downloadable content, such as PDFs of books, music downloads, or software. This article will show one simple way to accomplish this.
PHPMailer: Full Featured Email Transfer Class for PHP - Part 2
Reader Level:
PHP contains a mail function which sends script-generated email with very little configuration and ease. This built-in function, while easily accessible, provides only basic options for creating emails and requires a more manual effort to create advanced email features such html formatting and attachment encoding.
For many years, I have used PHPMailer which is an object-oriented PHP class that easily allows you to implement advanced email formatting. Features which can be readily tapped include: SMTP authentication, use of redundant SMTP servers, attachments, HTML formatting, multipart/alternative formatting for non-html email and various encoding methods. Due to its ease of use and broad feature base, I incorporate the PHPMailer class into all my scripts which send email.
My primary reason for using this class comes from the ability to send script-generated email through authenticated SMTP servers which dramatically reduce the risk of the email being trapped in spam filters. In my testing, mail sent directly from the server by the mail() is significantly more likely to be caught by ISP spam filters due to the fact that it resembles robotically generated spam. I also enjoy the relative ease of adding attachments, html formatting and using multipart/alternative text for email client preview.
In Part 1, I demonstrated how to install the PHPMailer class and use it to create simple email, while sending through an authenticated SMTP server. Use of this class requires some knowledge of working with server files and directories and some experience with PHP classes.
Here in Part 2, we will take it further and go over adding attachments and creating HTML emails.
The PHPMailer - Full Featured Email Transfer Class for PHP Series:
PHPMailer: Full Featured Email Transfer Class for PHP - Part 1
PHPMailer: Full Featured Email Transfer Class for PHP - Part 2
PHPMailer: Full Featured Email Transfer Class for PHP - Part 1
Reader Level:
PHP contains a mail function which sends script-generated email with very little configuration and ease. This built-in function, while easily accessible, provides only basic options for creating emails and requires a more manual effort to create advanced email features such html formatting and attachment encoding.
For many years, I have used PHPMailer which is an object-oriented PHP class that easily allows you to implement advanced email formatting. Features which can be readily tapped include: SMTP authentication, use of redundant SMTP servers, attachments, HTML formatting, multipart/alternative formatting for non-html email and various encoding methods. Due to its ease of use and broad feature base, I incorporate the PHPMailer class into all my scripts which send email.
My primary reason for using this class comes from the ability to send script-generated email through authenticated SMTP servers which dramatically reduce the risk of the email being trapped in spam filters. In my testing, mail sent directly from the server by the mail() is significantly more likely to be caught by ISP spam filters due to the fact that it resembles robotically generated spam. I also enjoy the relative ease of adding attachments, html formatting and using multipart/alternative text for email client preview.
In this tutorial, I will demonstrate how to install the PHPMailer class and use it to create simple email, while sending through an authenticated SMTP server. Use of this class requires some knowledge of working with server files and directories and some experience with PHP classes.
In Part 2, we will take it further and go over adding attachments and creating HTML emails.
The PHPMailer - Full Featured Email Transfer Class for PHP Series:
PHPMailer: Full Featured Email Transfer Class for PHP - Part 1
PHPMailer: Full Featured Email Transfer Class for PHP - Part 2
Creating CSV Files from Recordsets in PHP - Part 2
Reader Level:
Downloading comma-separated value (CSV) results is a common task in web development. If you have an e-store, for example, you may want to download orders, products, or customers. There are hundreds of other uses—search results, school lists, movie titles, book lists, tables of contents, access reports, web stats, etc.
Part 1 of this series showed a basic CSVFile class with the ability to create a CSV file download from any recordset. This part will show how to make a few tweaks in the class to allow Excel file downloads. The class is already built—all you do is call it. The class does not create a file on the server—it simply streams the content to the user as a file, not cluttering up your server or creating files that then have to be deleted. The article builds on the files used in the last part and simply makes a few changes to them.
The CSV Files in PHP Series:
Downloading PHP Recordsets as CSV Files - Part 1
Creating CSV Files from Recordsets in PHP - Part 2
Downloading PHP Recordsets as CSV Files - Part 1
Reader Level:
Downloading comma-separated value (CSV) results is a common task in web development. If you have an e-store, for example, you may want to download orders, products, or customers. There are hundreds of other uses—search results, school lists, movie titles, book lists, tables of contents, access reports, web stats, etc.
PHP 5.1 has a new function called
fputcsv to write a line to a file, but this article will show a technique that will work in older versions of PHP, and is generally very easy to use using a PHP class I wrote a while back. The class is already built—all you do is call it. The class does not create a file on the server—it simply streams the content to the user as a file, not cluttering up your server or creating files that have to then be deleted. I've found over the years that dealing with files on a PHP server has created the worst nightmares for beginning PHP developers. Setting and maintaining the correct file and folder permissions are somewhat of a black art.
The CSV Files in PHP Series:
Downloading PHP Recordsets as CSV Files - Part 1
Creating CSV Files from Recordsets in PHP - Part 2
Code Igniter - Controllers
Reader Level:
Delve in to controllers and views for Code Igniter, the basics to get the framework up and running for your site! Code Igniter is an open source PHP framework.
Code Igniter Introduction
Reader Level:
Code Igniter, a PHP framework that cooks, cleans and does the dishes. Even comes with a kitchen sink! Code Igniter will spoil you with flexibility, usability and functionality—and then you'll see the manual and never again be satisfied with other product's "documentation"...
From Create a Site to Connecting to a Database
Reader Level:
If a picture is worth a thousand words - then a video should be worth millions (if, of course, you account for the 15 frames per second)! In my first video tutorial for Community MX, I am going to show how to set up a new Dreamweaver site using the basic site set up, set up a database on a Linux based server utilizing CPanel and then how to connect to the database.
Approximate download size: 26MB
mySQL Groupies and Subcategories
Reader Level:
You need to get all of the categories for each product listed in a report - doing the heavy lifting in PHP seems to take the server extra time to get the work done. Learn about using the GROUP_CONCAT command in mySQL to make quick work of this problem.
Moving A Web Site: Preserving Search Engine Rankings and the Customer Experience
Reader Level:
Have you discontinued a product or renamed your service? Do you need to redirect visitors from an old web site domain to a new web site domain? This tutorial will show you how to use Apache server redirection to automatically transfer incoming traffic from the old site to the new. Additionally, we will use a code to tell the search engines about the permanent change so it will update its index.
What the automatic server redirection will not do, however, is inform the visitor of why they suddenly find themselves at a different website. Using PHP, I will show you a second step which will allow you to display a contextual note to visitors about the change. I devised this extra step to enhance customer service and educate longtime visitors about the changeover. Because this information is displayed only to redirected users, it will not distract new or potential customers.
Copy a Record in PHP Using Dreamweaver
Reader Level:
A quick and easy way to copy a record, edit the record contents and insert it as a new record in to your database. By using Dreamweaver server behaviors, this process is a snap!
PHP Phreakout: Troubleshooting Tips for PHP Code
Reader Level:
I call it the "White Screen of Oblivion." You've seen it. You just finished your new code and you eagerly upload it to the server to watch the magic you just conjured. You load the script and wait. And Wait. That white, blank screen opens like a void and sucks your confidence while the concept quickly sinks in that you have a problem. Ok, but what problem? Not even an error message?
With experiences like that, we can actually be happy when we do receive an error message. Even one which says fatal. At least an error message gives us a line number and some kind of a clue!
So what happens when your PHP code doesn't work as expected? What do those messages mean? Sometimes confusing, sometimes cryptic, those little blurbs declaring that you goofed can actually be helpful! In this article, I will describe the process and some tricks I use to troubleshoot my PHP code during initial development.
Case Study: How to Customize a JumpStart
Reader Level:
The primary benefits to the JumpStarts are that they have been tested with the popular browsers and can get you up and running quickly. Having a limited timeframe to get the site redesigned, I decided to give the JumpStarts a good look. What I quickly realized is that despite my disdain for templates, the JumpStarts are highly customizable, which can result in uniques designs.
In this tutorial, I will describe the process I used for assessing my web site needs and selecting a specific JumpStart. We will then walk through the steps of creating a unique design from the example. Finally, I will share an extra step I took in which I used PHP to 'templatize' my page design to speed content creation, ease revisions and provide customized content to the visitor.
Using Quotes in PHP
Reader Level:
One of the confusing things for beginning PHP developers is how to use single and double quotes. Unlike some other languages, like ColdFusion, single and double quotes in PHP are treated differently. This article will show how to use quotes in different situations in PHP.
The Secret Art of Cookies: Part 2
Reader Level:
Preserving data for an end user can be one of the more challenging tasks when you first start to learn a server-side programming language like PHP. Sessions are a good starting point that allow you to carry information about users across multiple pages of your site, but alone they can fall short of expectations as they are always only limited to the length of a current browsing "session".
In the first part of this series we looked at what cookies were, how easy they were to use, and some of the general pitfalls that developers need to be aware of when utilizing them. Today we're going to focus on setting the record straight on cookie security and the realities of using cookies in your own web applications.
The Secret Art of Cookies Series:
The Secret Art of Cookies: Part 1
The Secret Art of Cookies: Part 2
Creating a Redirected Login
Reader Level:
Creating a two-tier web site is a task that most developers have to deal with regularly; often times a site will require both a public and "member's-only" section. Although there are many tutorials and explanations of how to use databases to build and manage login systems, one of the questions that I find often goes unanswered is how to make your login page "transparent".
In this article we'll take a look at the theory and a simple implementation of how you can go about presenting a login page anytime a user is directed to "member's-only" content and, most importantly, how to continue sending them to their desired page once the login is complete.
Controlling the Serial Port with PHP
Reader Level:
When you think about the things a web server can do, they typically tend to be related strictly to the virtual world of web sites and electronic content. There are times however when a web server can do what most people would never expect: interact with the real world!
In this article we're going to take a look at an how we can use PHP to control other, non-web related systems, using a serial port.
Autoloading Classes in PHP
Reader Level:
When working with object-oriented coding in PHP one of the biggest hassles you'll encounter is having to continually remember to explicitly include/require the appropriate class definition file for each object you want to use. In this article we'll take a look at a new and very handy feature introduced in PHP 5 that will allow you to automatically include class definitions as they're required:
__autoload.
A VIEW to Die For!
Reader Level:
mySQL v5 introduced the VIEW command to create views in the database, we will go over the how, what and why of VIEWs for mySQL v5.
Is it read yet?
Reader Level:
When you browse the Community MX articles, have you noticed the details where it tells you if you've read it before or not? Do you want to do that on your site? Read on...
A Simple Error Handling Function for PHP
Reader Level:
Error handling is an important aspect of site development, but using PHP there aren't too many clearly defined ways to handle errors. I will present a simple function that handles errors in several ways: records the error in a log, emails the site administrator a copy of the error, and redirects the user to a central error page. Using one or more of these three methods, you can handle errors more gracefully in your PHP pages.
Creating a Master/Detail Pageset on One Page Using AJAX
Reader Level:
Dreamweaver's Master/Detail page set is a handy set of behaviors to use for a drill-down functionality -- display a list of records, and click on a link in the list to view the full record. Using the behaviors, however, you typically create two pages. If you create one page with both, the page will refresh each time you click on a link.
In this tutorial, I'll show how to create one master/detail page that uses some very simple JavaScript to load the details section of the page dynamically using AJAX. This tutorial will apply to PHP, ColdFusion, and ASP, with the concepts applicable to the other available server models that Dreamweaver now supports.
Automatic Code Highlighting in PHP
Reader Level:
Sometimes it seems that one of the hardest parts of teaching coding to others is simply getting your source coding to display in a properly formatted and easy-to-understand way. In this article we'll look at one of the built in tools that PHP makes available to you, as a web developer, that is designed specifically to address and solve this problem.
The Secret Art of Cookies: Part 1
Reader Level:
Preserving data for an end user can be one of the more challenging tasks when you first start to learn a server-side programming language like PHP. Sessions are a good starting point that allow you to carry information about users across multiple pages of your site, but alone they can fall short of expectations as they are always only limited to the length of a current browsing "session".
What about those times when you want to preserve information (such as a user's login) for a longer period of time? This is where the wonderful world of cookies comes in! In this article we'll explore what cookies are, why they're userful, and how to use them in PHP.
The Secret Art of Cookies Series:
The Secret Art of Cookies: Part 1
The Secret Art of Cookies: Part 2
PHP Sessions - Keeping Data Over Multiple Pages
Reader Level:
One of the age old problems with server-side scripting is that it's based on a page-by-page production model; that is, each page is interpreted and run as its own entity as the user requests it. While this makes development more inline with traditional HTML, it also makes it more challenging to create full-fledged applications that may span multiple "pages" of a site.
If you're new to PHP (or indeed most server-side languages) the desire to have variables or data persist across multiple pages has probably arisen several times, but a straightforward explanation of how to do this is often overwhelmingly difficult to find. The purpose of this article is to provide with practical knowledge of both the theories and actual code that you need in order to carry data across multiple PHP pages.
The World's Easiest PHP/MySQL Testing Server
Reader Level:
Setting up a local testing server can be a real pain at times, especially when you want to do more "complex" testing involving PHP, MySQL and Apache. Although there are some good installation packages out there, they can still at times be difficult and frustrating to work with and maintain. In this article we're going to take a look at what has to be the simplest and easiest "local testing server" set up possible: the Uniform Server.
Custom PHP Settings With .htaccess
Reader Level:
Every now and again I find as a web developer that there are times when the default PHP configuration on my server just isn't working as well as I'd like it to for a given project. This can be especially plaguing when you're dealing with remote web hosts that offer you little to no control over the configuration of PHP itself. Anytime you're running multiple web sites off the same server this can also be a problem as you may want to have different PHP settings for each of the sites.
In this article we're going to take a look at one possible solution to these problems by including PHP configuration values within an .htaccess file.
The PHP Insert Bar Explained
Reader Level:
The PHP Insert bar is a collection of commonly used programming features in PHP. The collection is used to insert a snippet of PHP code in the page and relies upon you to complete the variable information. We will walk through each of the icons on this bar and detail what it does and how to make it complete for your purposes.
Create a Table-less Horizontal Looper in PHP
Reader Level:
Dreamweaver has a Repeat Region server behavior that loops through your data and allows you to display it in a vertical or horizontal manner. If you want to display the data in a grid pattern, however, it requires a little more effort. Typically, a Horizontal Looper extension or code is used to create a table and put your individual data sections in a table cell. In this tutorial, I'll show how to do that using <div> tags and CSS without tables.
For this tutorial I'll assume you know how to use MySQL tools to create and manage databases, and how to create connections for PHP in Dreamweaver.
Anti-Spam Measures for PHP and ColdFusion - Part 2
Reader Level:
Spam, spam, spam, spam. Spammers have taken over the Internet and made it a horrible place to maintain a web site. Spammers have gone beyond simply spamming your email account -- now they are spamming blogs and guestbooks, spamming trackbacks, and spamming signup forms. Even a child's home page with a guestbook for friends is not safe from links for cialis, porn, or web hosting. Obviously these spammers are getting some return from their criminal activity, because they keep doing it. Unfortunately, you can't reach through the computer screen and grab them by the throat to strangle the life out of them. All you can do is put in place some safeguards and try to minimize the attack. Part 2 in this series shows how you can record the IP address of the spammer and block access to your site to that computer in the future. Once again, I'll assume you have familiarity with PHP or ColdFusion basics (databases, inserting and displaying data) and HTML forms.
The Anti-Spam Measures for PHP and ColdFusion Series:
Anti-Spam Measures for PHP and ColdFusion - Part 1
Anti-Spam Measures for PHP and ColdFusion - Part 2
Anti-Spam Measures for PHP and ColdFusion - Part 1
Reader Level:
Spam, spam, spam, spam. Spammers have taken over the Internet and made it a horrible place to maintain a web site. Spammers have gone beyond simply spamming your email account -- now they are spamming blogs and guestbooks, spamming trackbacks, and spamming signup forms. Even a child's home page with a guestbook for friends is not safe from links for cialis, porn, or web hosting. Obviously these spammers are getting some return from their criminal activity, because they keep doing it. Unfortunately, you can't reach through the computer screen and grab them by the throat to strangle the life out of them. All you can do is put in place some safeguards and try to minimize the attack.
The Anti-Spam Measures for PHP and ColdFusion Series:
Anti-Spam Measures for PHP and ColdFusion - Part 1
Anti-Spam Measures for PHP and ColdFusion - Part 2
Smarter Link Lists With PHP
Reader Level:
On most personal web sites you will find a listing of the the author's favorite sites, but often these links become outdated, or the sites at the end of the links go down for whatever reason. It's very frustrating for users to click on a link, only to be given a 404 page or timeout error, so in this tutorial I will show you how to make a smarter link list that checks to see if the domain being linked to is available or not before printing the link.
Server-Side Includes in PHP - Part 1
Reader Level:
Server-side includes are one of the most important concepts for web developers today. They not only save you time but also make sites easier to update and maintain while reducing redundancy and duplicate pieces of code. The cavet that most new developers run into is that although the idea of server-side includes in general seems quite simple, often the implementation can be quite frustrating if not planned out correctly. In this article we'll talk about not only the theory, but also some practical examples, of how to properly implement server-side includes using PHP.
The Server-Side Includes in PHP Series:
Server-Side Includes in PHP - Part 1
Server-Side Includes in PHP - Part 2: Relative Paths
Coming Soon
Peronalized E-cards with Flash
Reader Level:
I know the busy season for sending out greeting cards to your clients and friends has passed, but you can plan ahead for next year as well as using this tutorial for sending out any customized info and greetings throughout the rest of the year.
Nicely designed e-cards using Flash can send an effective, fully animated-greeting and message to your clients/friends. It also saves you a bundle in printing and mailing costs that come with hard-copy cards and mail-outs. If you're like me and you wait to the last minute with things, you can send them out much later and not have to worry about the time mail takes to get to places on-time!
This tutorial covers using PHP, URL encoded strings, FlahVars, and Flash to send out an address to a simple Flash e-card template that is personalized for each recipients name.
Validating Select Fields
Reader Level:
One very commonly asked questions when people begin processing data from forms using PHP is "How do I validate select fields and make them sticky?". The solution is very simple, and in this tutorial we will look at two scenarios for validating and creating sticky select form fields.
CMX PHP Download Counter
Reader Level:
So, your site offers it's users downloadable files of some sort, but you have no way of knowing how many files are being downloaded? Well CMX has has a solution for you.
The
CMX PHP Download Counter consists of two tiny PHP functions that use MySQL tables to generate lists of file downloads and count the total file downloads each time someone clicks on the link.
Multiple Insert/Update in PHP - Part 2
Reader Level:
Dreamweaver has some built-in tools for doing database inserts and updates, but they only handle basic inserts/updates of one record. What if you want to insert multiple records at a time, or update multiple records? Dreamweaver is no help in this case, but using PHP the process is simple. The first part of this tutorial showed two often-used methods for doing multiple inserts. Part 2 will show how to do a multiple update using these two techniques.
The Multiple Insert/Update in PHP Series:
Multiple Insert/Update in PHP - Part 1
Multiple Insert/Update in PHP - Part 2
CMX PHP Breadcrumbs
Reader Level:
As a web site's content grows, so does it's need to ensure that users can navigate around it in the easiest possible ways. In larger web sites it's very simple for users to lose track of their orientation within a site.
Enter breadcrumbs... A very simply way to keep your users oriented, as well as giving them instant access to the pages closest to the one that they're viewing. Using the directory structure of a web site is the easiest way to implement breadcrumbs using PHP. In this tutorial we will look at creating a simple function that will automatically generate a breadcrumb trail in valid and semantic (X)HTML.
Generating ATOM feeds with PHP
Reader Level:
Web site content syndication is a very commonly used method of sending new content updates via desktop software that is able to read and make sense of the XML languages used in RSS and ATOM. These XML files are generically known as "feeds". They are prevalent in most blogging applications and some forums, but recently they have started to appear on almost every site that is updated on a regular basis.
In this tutorial we will look at generating an RSS feed from a very simple MySQL table using PHP.
Multiple Insert/Update in PHP - Part 1
Reader Level:
Dreamweaver has some built-in tools for doing database inserts and updates, but they only handle basic inserts/updates of one record. What if you want to insert multiple records at a time, or update multiple records? Dreamweaver is no help in this case, but using PHP the process is simple.
This tutorial will show two often-used methods for doing multiple inserts and multiple update. The files
testinsert.php and
testinsert2.php are included in the download package showing the final code for both methods. Part 1 of this series will show how to do inserts and Part 2 will show how to do a multiple update using these two techniques.
The Multiple Insert/Update in PHP Series:
Multiple Insert/Update in PHP - Part 1
Multiple Insert/Update in PHP - Part 2
Hand-Coded User Authentication
Reader Level:
One of Dreamweaver's most treasured features is its ability to allow developers a quick and painless way to authenticate users via a login form. While this is pretty cool if you don't want to dirty your hands with code, it doesn't allow you much insight into how it actually works.
In this tutorial we will explore hand-coding a small PHP script that allows you to restrict access to pages, and also redirect users to their own personal page when they log into your application. We will use MySQL to store user information.
So, if you're not frightened of some code, and you want to see how sessions can be used to help developers deliver user-specific content please read on.
Editable Select Lists Using CMX AutoComplete
Reader Level:
One of the most surprising aspects of HTML forms is that there is no way to natively create an editable select list. Developers are forced to either present a fixed value list for the user to choose from, or provide an additional text box to allow the user to enter a new value. Fortunately with a bit of help from the latest version of the
CMX Auto Complete Extension we can finally solve this problem quite easily!
Switching CSS Based on Time of Day with PHP
Reader Level:
Sometimes dynamic code can have advantages when it comes to adding some aesthetic features to a web design. In this example we will build a small PHP function that will output a different CSS link to your pages depending on what time of the day it is. We will also have a look at the best way to deploy this technique in terms of CSS.
We will take advantage of PHP's date function and switch statements to make our function work.
The support files download for this tutorial contain a nice looking example of a CSS header image rotation based on the time of day. It's complete with the 4 PNG files used, CSS files, PHP function and test page.
Approximate download size: 658k
Implementing a Real-Time Chat Application
Reader Level:
When you look around the internet you will find a multitude of community-style sites that offer their visitors the opportunity communicate via a real-time chat application. Many of those applications are cumbersome and rely on terrible page refreshes every few seconds.
The fact that chatting online is a very important part of building friendship and communication within a community web site makes it no surprise that a frequently asked question on web development forums is "How do I add live chat to my web site?". It's a common question with so many possible answers.
In this tutorial I will introduce you to a free PHP chat application that works in modern browsers and degrades gracefully in the not so modern browsers that some people still persist in using.
This application is special for a number of reasons. To find out just how special it is please read on.
Previewing and Submitting User Content
Reader Level:
Often when you allow users to send data to a database it's a good idea to allow them to preview their text before it's committed, especially if the data is going to be queried and outputted onto a live HTML document. This is a common feature of many forum, CMS and blogging applications. In this tutorial I will show you how to acheive this using PHP.
Regular Expressions By Example
Reader Level:
Regular expressions are a powerful pattern-based tool for searching and manipulating text. Unfortunately for newcomers they can also seem quite complicated and often times be simply overwhelming.
In this article we'll take a bit more of a hands-on approach to regular expressions and see how some of the various symbols and characters of regular expressions can be combined to form patterns that have real world practical uses.
Implementing Gravatars with PHP
Reader Level:
What with all those blogs, forums, galleries and other applications that allow web site users to add their own comments on pages it was little wonder that someone decided to create universal method of graphically identifying users.
Gravatars are an adaptation of the good ole' fashioned forum "avatar". The main difference with Gravatars is that they are served from a single place, instead of individual servers. The idea being that no matter where you're posting comments, your avatar will always be the same. Also when you change the image it changes everywhere you have left a comment too! Cool huh?
Let's say you have created an application in PHP and you wish to allow your users to take advantage of Gravatars. How would you do this? Let me show you the easiest method.
Introduction to Regular Expressions
Reader Level:
One of the most common tasks as a programmer that you'll end up coming across is string manipulation. You can run from it, you can hide from it, but eventually you're going to have to end up doing it (and usually on a fairly frequent basis!). Fortunately, a special set of tools commonly called "regular expressions" can often save you a great deal of time and effort, helping you achieve goals that you never thought possible. The downside, of course, is that you have to learn how to use these "expressions", and they can be quite confusing at times.
In this article we'll take a beginner's look at what regular expressions are and see through examples how they can help you in your day to day tasks.
PHP Formmail Spam Prevention
Reader Level:
It used to be that there were clear sides in the junk email battle: the spammers and the spammed. I always considered myself a member of the latter group, and then one day I became a member—inadvertently—of the former. I had become a victim of the email injection attack via a PHP formmail script.
In this update to the Dreamweaver Creating and Processing Form series, we'll take a new look at the phpformmail script and demonstrate how to use a key and email value pair to keep your email address out of the html page.
Tag Clouds with PHP and MySQL
Reader Level:
Tag clouds are all the rage these days when it comes to browsing content that's "tagged" with category keywords. They quickly provide users with a visual indication of which categories contain the most information.
Blogs and social linking networks have been quick to utilize this navigation pattern, but whether tag clouds are just the latest craze or a genuinely useful way for users to navigate content is very much a disputed topic.
In this tutorial we will be using some simple PHP and two simple tables from a MySQL database to illustrate a quick and easy method of outputting tag clouds.
Clever CSS Menus with PHP
Reader Level:
In this tutorial we will explore making an intelligent CSS menu system using a very simple PHP function.
While techniques exist in CSS that allow people to add current page indication based on body tags with classes applied to them they involve the editing of the individual pages to make them function. They also do not remove the current page's link from the navigation list.
This menu will automatically remove the link from the current page navigation list item and add an ID that will allow it to be styled with a current page indicator of some sort via CSS.
Let's get started.
Full-Text Searching with MySQL and PHP - Part 2: Search Term Highlighting
Reader Level:
In the
last tutorial of this series I showed you how to create a FULLTEXT index in MySQL and created a query with PHP that allowed you to search through dynamic content using a simple form.
In this tutorial I will show you how to style keywords found in content so that they are highlighted for easy reading.
Google is one such search engine that highlights keywords that the user searched for in the pages generated by the search:
This is very useful as it directs the user's eyes directly to the piece of text they are searching for even when it's jumbled up among lots of other words.
In this tutorial we will create the same effect with a tiny addition to the code from the last part of the tutorial.
Making Time-Triggered Scripts
Reader Level:
Most developers tend to think of server-side languages as user-driven applications; that is they sit dormant on a server somewhere waiting for a user to connect and make a request before actually doing anything. While this is true on many occasions, there are also times when server-side scripts need to start working without any user intervention. Unfortunately for developers who aren't entirely familiar with server environments and or are just starting out with a language this type of "non-user triggering" is fairly confusing and difficult because there aren't a lot of explanations in the server-side manuals that explain how to do it.
In this article we'll take a look at how you can acheive time-triggered (rather than user-triggered) scripting using PHP and a remote Linux server.
Full-Text Searching with MySQL and PHP
Reader Level:
As a general rule of thumb, web sites that contain a large amount of content adopt some form of fuctionality that allows users to search through content held within their database.
The methods for searching database content vary from server model to server model and can often be rather complicated. However, if your web site holds its content in a MySQL database, you can very quickly add a simple but effective search mechanism using MySQL's FULLTEXT indexing.
In this tutorial we will look at using FULLTEXT indexing to create a simple content search engine that can quickly be implemented on any web site running PHP and pulling content from a MySQL database.
Creating a Registration Page: Part 3
Reader Level:
Dreamweaver contains many built-in tools to aid in quickly building dynamic sites. Part 1 of this series showed the Record Insertion Form Wizard to set up a simple user registration form on a web site. The registration form allows a user to register for a site.
Part 2 showed validation and the user agreement, using more built-in tools of Dreamweaver and a little rudimentary JavaScript. The tutorial will apply equally to PHP, ASP, ColdFusion, and JSP using built in tools.
Part 3 will show how to pass registration details to Paypal or other payment processor for a paid membership-type of site.
The Creating a Registration Page Series:
Creating a Registration Page: Part 1
Creating a Registration Page: Part 2
Creating a Registration Page: Part 3
Creating a Registration Page: Part 2
Reader Level:
Dreamweaver contains many built-in tools to aid in quickly building dynamic sites. Part 1 of this series showed how to use the Record Insertion Form Wizard to set up a simple user registration form on a web site. The registration form allows a user to register for a site.
Part 2 will show validation and the user agreement, using more built-in tools of Dreamweaver and a little rudimentary JavaScript. The tutorial will apply equally to PHP, ASP, ColdFusion, and JSP using built in tools.
Part 3 will show how to pass registration details to PayPal or other payment processor for a paid membership-type of site.
The Creating a Registration Page Series:
Creating a Registration Page: Part 1
Creating a Registration Page: Part 2
Creating a Registration Page: Part 3
Creating a Registration Page: Part 1
Reader Level:
Dreamweaver contains many built-in tools to aid in quickly building dynamic sites. One such tool is the Record Insertion Form Wizard. Using this tool, I'll show how to set up a simple user registration form on a web site. The registration form will allow a user to register for a site (free site or membership site), and include a way for the user to agree to a user agreement and also opt-in/opt-out of a newsletter. The tutorial will apply equally to PHP, ASP, ColdFusion, and JSP using built in tools. This is the first part in a series.
Part 2 will show validation and the user agreement, and Part 3 will show how to pass registration details to Paypal or other payment processor for a paid membership-type of site.
The Creating a Registration Page Series:
Creating a Registration Page: Part 1
Creating a Registration Page: Part 2
Creating a Registration Page: Part 3
Create Dynamic Charts & Graphs with PHP/SWF Charts
Reader Level:
PHP/SWF Charts is a PHP-based tool to generate Flash charts and graphs from dynamic data. With it, you can create charts that update in real time, right on the same page. This tutorial will show you how to use the free version of PHP/SWF charts (along with PHP and MySQL) to create an opinion poll page where poll results are charted in real time.
Making Full Use of Bindings
Reader Level:
The Dreamweaver bindings panel has a lot of uses beyond a place to build recordsets and stored procedures. Many people don't realize that when you add session, request, and application variables to the panel manually, you get some visual advantages — the ability to drag items to the page into design view, the ability to use variables as filters, and the ability to add formatting functions to design view.
This article will explore the bindings panel and its advantages. Because we are discussing core Dreamweaver functionality, the article will apply equally to all server models in Dreamweaver, although some server models have better bindings panel support than others.
Spell Checking HTML Forms with JavaScript and PHP
Reader Level:
Have you ever had to write a large amount of text into a field on an HTML form and been uncertain of just how reliable your spelling skills are? Wouldn't it be nice if HTML forms, like most other applications, had one of those handy little "Spell Check" buttons? In this article we'll look at how easy it is to implement this functionality using a PHP/JavaScript solution called Speller Pages.
Speeding up AJAX with JSON
Reader Level:
XML is a brilliant tool for standardizing communication between two isolated systems. When you as a web developer have control over the way that both of those systems function though the benefits of XML quickly begin to fall short of the timing delays that it incurs. This is especially true of AJAX applications where you have control over both the client-side and server-side code, and thus usually don't need to waste the user's time by converting everything to XML and then back again for each transaction.
In this article we'll explore a more compact, and possibly more effective, approach to transferring complex data between two systems using JSON.
AJAX Applied: PHP Contact Forms - Part 2
Reader Level:
In the first part of this article we explored how to take a standard PHP-driven contact form and convert it to an AJAX-driven one. Although the AJAX version was better than the original, the conversion over to client-side validation also opened the door for some new and unexpected possibilities.
In this article we're going to explore one of those new concepts and refine our form a bit further by adding form validation that occurs in real-time as the user completes each field.
The AJAX Applied Series:
AJAX Applied: PHP Contact Forms
AJAX Applied: PHP Contact Forms - Part 2
Using JumpStarts with Cartweaver, Featuring Minneapolis
Reader Level:
JumpStarts are great starting points for dynamic sites, and the Minneapolis JumpStart is a great starting point for a dynamic e-commerce site. Shopping carts like Cartweaver integrate well with Dreamweaver, but how do you integrate a third-party cart with a JumpStart? This tutorial, written by a member of the Cartweaver team and Community MX, shows one way of integrating the two.
AJAX Applied: PHP Contact Forms
Reader Level:
For most web developers AJAX is simply another one of those "buzz words" that represents a "revolutionary new technology" that will change the way web sites work forever. It all sounds fantastic and there are lots of great articles that explain what AJAX is and why you'd want to use it. The biggest problem for most developers is figuring out just how AJAX can be applied to real-world situations.
In this article we're going to try and tackle the implementation question. We'll take an existing PHP contact form and gradually convert it into an AJAX-driven solution. The goal is to demonstrate not only the technology and how it can be used, but also the process that you, as a developer, can take to begin the transition from traditional web development to AJAX-based pages and sites.
The AJAX Applied Series:
AJAX Applied: PHP Contact Forms
AJAX Applied: PHP Contact Forms - Part 2
Geolocating IP Addresses with PHP
Reader Level:
Have you ever wondered just where in the world the visitors of your website are comming from? Whether to satisfy your own curiosity or to automatically deliver localized information, Geocoding can open a whole new set of possibilites for a web site. In this article we'll take a look at what Geocoding is and how a community-based project can help to provide an accurate and affordable geocoding solution.
Automating An Image Gallery with PHP and Your Local Server: Part 1
Reader Level:
Many developers have local testing servers running on their development machines to allow for quick offline tests of materials before they are sent to the live server. If you happen to be running a local server on your development machine though there's no reason that it's functionality should be limited to mere page testing. In this article we'll take a look at how you can utilize your local server as a scripting engine to increase your efficiency and perform common tasks more quickly then ever before.
The Automating an Image Gallery with PHP and Your Local Server Series:
Automating An Image Gallery with PHP and Your Local Server: Part 1
Automating An Image Gallery with PHP and Your Local Server: Part 2
Coming Soon
WordPress 2.0: Wonderful As Ever
Reader Level:
WordPress has always been both powerful and empowering, and the new 2.0 ("Duke") release is no exception. This review discusses the new features in the latest edition of WordPress, and offers tips on installation and/or upgrading.
Running PHP under ASP.NET??
Reader Level:
I won't lie, I am a Microsoft lover. Their technology has been paying my salary for just about my entire career, and C# totally rocks in my quite humble opinion. But that being said, any programmer worth their salt knows that a specific technology is nothing more than a tool. If a given situation could be solved more efficiently with the use of non-Microsoft technology, then its your responsibility to investigate and (potentially) use said technology.
This article is going to review a nifty little project called
Phalanger. Installing this on your ASP.NET web server allows you to deploy PHP code, even full applications like
phpBB. Behind the scenes, the PHP code will be compiled to .NET code and run as an ASP.NET application.
The best thing about it is that you can, from PHP script, access .NET code (in your language of choice), and vice-versa. So if you have a nifty function written in PHP, you can use it in your .NET application. The Developers tout
impressive performance improvements over the native PHP environement so this makes Phalanger an attractive target for your application platform.
Creating a Simple Blog: Part 6
Reader Level:
There have been five parts in the series on creating a simple blog. The first five parts focused on creating basic functionality to get a basic blog up and running using simple Dreamweaver design tools. This part will show how to incorporate the functionality into a more complex design — specifically, the latest CMX Jumpstart — Inverness. This tutorial will be equally applicable to ColdFusion, ASP, PHP, ASP.NET, or JSP because we will be using standard Dreamweaver server behaviors to create
the blog. In the course of merging the dynamic blog into the design, you'll learn the following about merging content with design in general — how to find repeating items and make them dynamic, how to separate parts of an existing design into a module.
Captcha the Bastards: Part 1
Reader Level:
Plagued by comment spammers? Captcha the bastards - a well-designed captcha implementation is your best weapon in the battle against comment and link spam. Part 1 of this article provides an overview of Captcha and introduces you to Captcha PHP, an excellent solution. Part 2 will provide all the setup details.
The Captcha Series:
Captcha the Bastards: Part 1
Captcha the Bastards: Part 2
Redirecting Users When Logging In
Reader Level:
While the article
Show and Hide Content Based on User Access Level discusses allowing content for multiple access levels (or user groups) to be held on the same page and showing portions of content based upon the user's group, sometimes you need each user group to get sent to different pages (perhaps within different folders). This article discusses how to enhance the existing Log In User Dreamweaver Server Behavior to allow redirecting users to specific pages based upon their access level when they log in.
A Gentle Introduction to SimpleXML
Reader Level:
Once upon a time PHP developers wishing to take advantage of XML when building their applications were forced to jump through many hoops in order to parse even the most simple XML documents.
PHP 5 however has proved to be a complete rethink of the way in which PHP is able to handle simple and complex XML documents. It sports a new extension called simpleXML that allows even the most novice of PHP developers to work with XML without the urge to tear their hair from its roots.
In this tutorial we will have a look at how PHP's simpleXML could allow us to utilize XML in the real world of web development.
Preventing Form Flooding and Double Submits
Reader Level:
When your sites allow users to input data via web forms it involves some risk on your part. One of those risks is flooding.
Flooding occurs when a user repeatedly inserts data in quick succession; either deliberately or by mistake. When flooding occurs by mistake it's usually because the user has either refreshed a page that still has HTTP request POST data set, or they have accidently pressed the form's submit button multiple times, the "double submit problem".
Recently many blogs have been plagued by a form of advertising that takes advantage of the ease in which a site's user can post visible content on a page. It's called "Comment Spam", and although it's almost impossible to prevent it can be limited to an extent by taking some simple measures to limit the rate in which people can send data via your forms.
In this article we will explore two methods that will ensure that you will never suffer the consequences of the double submit problem, and hopefully limit the impact of malicious user input.
Confirmation Emails
Reader Level:
Many sites and services require that you confirm your email address when creating accounts or subscribing to services for the first time. Although there are a fair number of ways that you can attempt to validate a supplied email address, the only real way to be sure of its validity is to use a confirmation email. In this article we'll take a look at how you can create such a confirmation system using PHP and MySQL.
Show and Hide Content Based on User Access Levels
Reader Level:
Dreamweaver's native Log In User server behavior combined with the Restrict Access to Page server behavior can help you protect your pages from prying eyes. However, when it comes to more fine grained control of content on pages viewable by users from multiple access levels, Dreamweaver doesn't have anything built in to offer any assistance to you.
Read on to learn how to show and hide content on a page based upon the access level (user group) of a logged in visitor.
Reading Flash Metadata with PHP
Reader Level:
Flash 8 is the first version of the SWF file format to support standardized, native metadata. This is a great new feature that has the potential to make SWF files easier to manage, organize, and even locate through search engines. Unfortunately there's one small catch; although Flash 8 has made adding metadata to your SWF files extremely simple, at the time of writing there are very few applications/scripts/bots outside of Flash itself that actually have the ability to read that metadata!
In this article we'll take a look at a custom PHP class that can be used to read SWF metadata, and how it can be used to realize some of these great new potentials.
Overcomming File Restrictions with PHP
Reader Level:
PHP offers a wide variety of file manipulation functions that can be used to create online content management systems as well as web-based control panels. One of the problems that many developers face when first implementing this type of solution though is file permissions. In this article we'll take a look at file permissions on UNIX-style servers, why they can be a hinderance to web-based administrative scripts, and how to overcome the problems that they can create.
PHP Contact Forms - Part 2
Reader Level:
In the first part of this tutorial we made a contact form using PHP's mail() function. In the process of creating our script to send the mail to your inbox we checked each of the form's fields to ensure they contained the data required.
In this second part of the tutorial we will look closely at CSS and some more PHP which will improve the way our form functions and looks.
The PHP Contact Forms Series:
PHP Contact Forms - Part 1
PHP Contact Forms - Part 2
PHP Contact Forms - Part 1
Reader Level:
The ability to receive feedback or enquiries from the people who visit your web site is always beneficial. If your site is hosted on a server running PHP, the creation of mail forms is a relatively simple task, made easier by one of PHP's built-in functions, the mail() function.
The PHP Contact Forms Series:
PHP Contact Forms - Part 1
PHP Contact Forms - Part 2
Teaching Dreamweaver Part 2
Reader Level:
Part two of my Dreamweaver course series is devoted to how I teach students to create database-driven web pages and web applications. During the course of the semester we put together a form that is processed by a script, a login system based on access level that uses Dreamweaver's Authentication Server Behaviors, and a blog as introduced in a tutorial by Tom Muck. In the process, the students learn the basics of the various skills they'll use: form construction, SQL, database and web application design, and server model concepts.
Random Queries (recordsets) For ASP, ColdFusion and PHP
Reader Level:
While most data displays on web sites are in some predetermined, or even user specified order, such as search results of a products table in product name order, it can be quite beneficial to display data randomly, such as random banners, or even random on sale products on the home page. This article will discuss how you can use ASP VBScript with Access and MS SQL Server; PHP with MySQL; and ColdFusion with Access, MS SQL Server and MySQL to generate random results, be it a single random banner from your advertisers, or five random products that are currently on sale.
Using PHP to Enable Client-Side Web Services
Reader Level:
You've just finished reading up about JavaScript's XMLHTTPRequest object when the light bulb goes on: Moving over to using XMLHTTPRequest has inadvertently forced you to deploy your own little web service! After all, if you think about it a web service is merely a remote server that you send and receive data from in a standardized format (usually XML). That's neat, but ultimately the next question arises: if a client uses XMLHTTPRequest to connect to your "web service" is it possible to use that same methodology (and code) to connect to any other public web service? If you've already gone ahead and tried this though you'll find that it's one of those "it should work but doesn't for some strange reason" problems. In this article we'll take a look at why it doesn't work quite the way you'd expect and a neat little solution to overcome the problem.
Introducing Recursive Functions in PHP
Reader Level:
One of the basic building blocks of any object-oriented programming language is the function. Functions allow you to reuse blocks of code and perform common tasks from other points within a script. In addition to straight calls though, functions can also be created to act recursively, adding a whole new dimension and power to this basic programming building block. In this article we'll take a look at what recursion is and why it's useful. We'll also create a recursive function to convert PHP arrays to JavaScript ones.
Base64 Encoding
Reader Level:
Your boss comes up to you, says that the requirements on the latest project have changed. You are now required to include an employee badge photo along with your company's replication feed. "But sir, the replication feed is an XML file ... how are we going to get an image into that?".
Enter Base64 Encoding. Though it doesn't come up every day, it's usefulness is undeniable, and your toolbox will be all the better for containing it. Code presented in this article will be in ASP.NET, Coldfusion, and PHP. We will discuss some situations where Base64 encoding will come in handy.
CMX JumpStart: Vienna
Reader Level:
Last summer we took a trip to Germany and Austria with our son's orchestra director. My favorite city was Vienna, Austria. So it is only natural that I should choose Vienna for my city as I "change hats" from JumpStarts marketer to JumpStarts creator. I am particularly pleased and excited to offer our latest CMX JumpStart:
Vienna.
In addition to the use of valid XHTML 1.0 and CSS 2.1, and in addition to validating for 508 and WAI, we have a number of special features in Vienna. This three column layout has two outer columns with fixed widths, a fluid center column for content, and fluid header and footer. There are also unordered lists for navigation: one for the main navigation, one for the sub navigation, and one for the footer navigation. We have also added a search field into an area that is at the top of the page outside the main centered layout. So far, reasonably cool, right?
But hold on. We have something far more exciting to reveal with this JumpStart. We will introduce a new and revolutionary technique called
Jello Mold that has an implied minimum and maximum width that works in Internet Explorer without the use of Javascript! Furthermore, this technique allows for fluid margins on the fluid centered layout that depend on the size of the user's window.
The download folder for this article includes a bundle of 11 articles (including two about
Jello Mold technique), a starter page, an images folder, four style sheets (including design-time and print), a source png, the Vienna extension, an installation and usage guide, and this article as a PDF.
Creating a Search Engine with iSearch
Reader Level:
If you have always wanted to add a search engine to your site, and didn't know how to program one yourself, you might want to download and install iSearch, a ready-made PHP and MySQL driven application that performs searches right on your own server. This tutorial will take you through the installation and the customization (of the style sheet and header and footer includes) of iSearch.
PHP Image Series: Part 6 - Building a Photograph Album
Reader Level:
In Part 6 of the PHP Image Series we will start building an application utilizing the topics discussed in the previous aritcles in the series. The application is a photograph gallery that has features such as batch upload (using ZIP files,) dynamic borders, watermarks, and graphs. In this article we'll build the basic database structure for the tables that will hold the photograph, album, and category data. Additionally, we'll build the PHP interfaces for adding albums, categories, and uploading photographs.
The PHP Image Series:
PHP Image Series: Part 1 - Basic Drawing
PHP Image Series: Part 2 - Fills
PHP Image Series: Part 3 - Gradients
PHP Image Series: Part 4 - Text
PHP Image Series: Part 5 - Bitmapped Images, Compositing, and Watermarks
PHP Image Series: Part 6 - Building a Photographic Album
PHP Image Series: Part 7 - Building a Photographic Album (Continued)
PHP Image Series: Part 8 - Building a Photographic Album (Continued)
PHP Image Series: Part 9 - Building a Photograph Gallery Application (Continued)
Creating a Simple Blog - Part 5
Reader Level:
One of the frequent questions in the forums is "How do I create a blog?". There are many commercial blog systems out there, and many full-featured blog providers, like Blogger, but you can also create a simple blog using the standard tools of Dreamweaver. This tutorial will be equally applicable to ColdFusion, ASP, PHP, ASP.NET, or JSP because we will be using standard Dreamweaver server behaviors to create the blog. This fifth part of the series will describe how to add a design to the blog, including a sidebar with category, blogroll, and RSS modules.
Dynamic CSS Files with PHP
Reader Level:
Dynamically generated CSS adds a whole new level of managability and optimization to CSS. In this article we'll take a look at how to put PHP scripting within your CSS files, and some of the advantages of doing so.
Basic FTP in Your PHP Scripts
Reader Level:
Although many developers regard PHP simply as a tool for dynamic web sites, there are many situations in which it can be used to make a web administrator's job easier and more efficient. In this article, we take a look at PHP's native FTP functionality, and how it can be used to help automate the task of creating and updating a Froogle data feed.
PHP Site Simplification with Application.php
Reader Level:
PHP and ColdFusion have many things in common, but they also have many differences. One of the nice features of ColdFusion that I wish I had in PHP is the Application.cfm. In the Application.cfm file, you can include things that need to be on every page, such as variables that contain connection information, often-used functions, login functionality, class instantiation, session starting, and form field cleaning, among other things. In ColdFusion, the Application.php file is automatically executed before any code on your page. To mimic this functionality in PHP, I like to create an Application.php file that I include on all my PHP pages. This article will show how an Application.php file can be used to simplify some aspects of your PHP application.
CMXMail: Creating a Generic Mail Class in PHP - Part 2
Reader Level:
PHP has a lot of built-in functions, but for dealing with emails it is not the most friendly language, including only a generic mail() function. A way around these limitations is to use an email class to handle setting up the messages and sending them so that you don't have to create custom headers each time you use the mail() function.
Part 1 of this tutorial showed how to create a basic class. Part 2 will add to that class, and also show how to use the class in a loop, effectively creating a newsletter engine to send emails to a database.
The tutorial assumes you have set up databases and connections from PHP to MySQL.
PHP Zip
Reader Level:
Learn how to read ZIP archives using PHP. In this article you'll learn the basics of reading data from ZIP archives, and how to extract the files, and recreate the directory structure.
Liverpool JumpStart with .NET
Reader Level:
Ah yes, Liverpool, not only a great JumpStart, but now you can have it with ASP.NET support. In addition to a valid CSS2 and XHTML 1.0 Transitional, WAI and 508 Accessible CSS layout, you also get a dynamic ASP.NET login application. The original release of the Liverpool JumpStart comes bundled with ColdFusion, PHP, and ASP and uses Dreamweaver's built-in User Authentication Server Behaviors. Unfortunately, Dreamweaver doesn't boast similar server behaviors for ASP.NET. To help make up for that lack, here's a special tutorial just for you ASP.NET coders. I've taken the original Liverpool JumpStart pages and added the necessary ASP.NET code. The result: an out-of-the-box ASP.NET login solution combined with a versatile layout. What could be better? :-)
Included in the support files are the CF, ASP and PHP versions of the Liverpool JumpStart. There is a link at the end of the article that will allow you to download just the .NET version if you prefer, as well as a link to download the bundled tutorials that were included with the original Liverpool JumpStart.
The .NET version of Liverpool is available as a no charge upgrade to purchasers of the original Liverpool JumpStart.
If you would like to receive the .NET version, please
send us an email and we will send you the .NET files. Please be sure to include your name and the email address that is associated with the PayPal account used to make the purchase.
CMXMail: Creating a Generic Mail Class in PHP - Part 1
Reader Level:
PHP has a lot of built-in functions, but for dealing with emails it is not the most friendly language, including only a generic mail() function. You have to create your own mail headers, set up separate text and HTML messages if you want to send multipart messages, and add your own attachment code. One way around this is to use an email class to handle setting up the messages and sending them so that you don't have to create custom headers each time you use the mail() function. Part 1 of this tutorial will show how to create a basic class that you can later add to.
Announcing CMX JumpStart: Liverpool
Reader Level:
It was the early sixties, and all the world was in a frenzy over a new group from Liverpool, England called
The Beatles. They revolutionized rock 'n' roll music, and the world has never been the same. Maybe the Web Standards movement doesn't stir
quite that much excitement, but it is changing the Web world all the same. And because we "love you, yeah, yeah, yeah" we're here to help you join the revolution.
Community MX is pleased to announce the release of its fifth CMX JumpStart: Liverpool. This time we're giving you more than a CSS layout, however. We're also giving you a dynamic ColdFusion login application built with Dreamweaver's User Authentication server behaviors that will allow you to quickly and easily edit the login.
This article will tell you all about what this fantastic package includes--bundled tutorials, an authentication system, a two-column, fixed width layout (with a little bit of a twist), original PNG files, and more.
Access Level and Login For PHP
Reader Level:
Dreamweaver has many tools to help simplify page creation. Beginning with Dreamweaver MX 2004, Dreamweaver contains Server Behaviors for password protecting PHP pages in your site. This tutorial will show how to password protect your pages using a username, password, and access level defined in a MySQL database.
Handling File Uploads With PHP
Reader Level:
Whether you want to give your web site visitors the ability to manage their own content or simply to post pictures for personal photo galleries, knowing how to handle file upload forms is an important and extremely useful skill to have. In this article, we'll take a look at how file uploads work and how to handle them in PHP.
Creating a Subscribe / Unsubscribe Feature Using PHP and MySQL
Reader Level:
Want to add a mailing list to your site? Learn how to do just that by enabling people to subscribe and unsubscribe via a PHP interface with a MySQL database. This article shows you how you can create a database, send automatic emails when people subscribe and unsubscribe, validate email addresses with JavaScript, and more.
On the Fly: Generating PDFs From PHP
Reader Level:
There are a number of ways you can create PDF files from PHP, and this introductory article will examine several. We'll show you how to enable PHP PDF generation on local and remote servers, and how to generate text, draw shapes, include images and build tables. A follow-up article will outline the process dynamic PDF generation using templates.
Dreamweaver Piece by Piece Part 5: Creating and Processing Basic Forms Part 2
Reader Level:
In the first part of our basic forms series, we learned how to configure Dreamweaver form preferences, set up the form with the proper actions and method, and use many of the different kinds of form objects such as text field, textarea, radio groups, and checkboxes.
In this second article in the series, we'll look at the menu/list form object, add our submit and reset buttons, use the validate form behavior, learn to set file permissions, and configure our PHP form processor. Also included in this article are both a ColdFusion and an ASP form processor for those who do not have PHP available on their servers.
Dreamweaver Piece by Piece: Part 4 - Creating and Processing Basic Forms
Reader Level:
The ability to interact with users is one of the great lures of the Internet for businesses and individuals. Most of you have filled out a form on the Internet, then hit the submit button to send your data off into cyberspace. How is it done? Most instructions give the old "setting up the script is beyond the scope of this tutorial" line, which has long been a frustration to many Web designers. I hope that this article helps you set up a feedback form that actually works. In part one of this series, we'll configure Dreamweaver form preferences, set up our form, and cover most of the different types of form objects developers will use when creating interfaces for interacting with users.
Using Image Metadata in PHP - Part 2
Reader Level:
In
Part
1 we took at look how to read metadata from images in PHP using the JPEG-Meta class. This time around we take a look at how to use the same class to write and update metadata back to our images, giving us a complete JPEG metadata solution for our PHP applications.
Using Image Metadata in PHP
Reader Level:
The rise of the digital camera has brought significant changes to the way in which we interact with and experience images. Most web-based photo galleries though don't begin to explore the full potential of digital pictures. This week we'll take a look at the importance of metadata, and how we can use it in PHP to make our digital images more portable, better organized, and more effective to our viewers.
A Clean Start: The New PHP 5 SOAP Extension
Reader Level:
PHP 5 now comes with its own SOAP extension, and that makes implementing cross-platform web services solutions easier than ever. This article will show you how to enable and use the new extension to create a basic web service client that taps the power of Google's Search API.
Using Flash Remoting with PHP: AMFPHP
Reader Level:
Flash Remoting is
the way to build Flash applications that interact with a business tier on the server. It is fast, efficient, and scalable. In this article learn how to use the free AMFPHP Flash Remoting gateway in order to get started building more sophisticated applications.
PHP Server Communications Using cURL
Reader Level:
In today's world of web services and real-time inter-server communications, it's easy to get lost in the wide array of possibilities and technologies that are available for server-side data sharing. In PHP, the ability to use Client URLs directly inside regular scripts provides a powerful but simple solution to a wide variety of server communications scenarios. In this article, we'll take a look at what Client URLs are, how they work, and some of the ways they can be used to create a more complete web experience for end users.
Basic String Manipulation
Reader Level:
Working with text, or "strings", is one of the most important skills a new developer can learn. In this article we'll take a look at strings, how and why they are so useful, and get a feel for working with them in PHP. Beginning with the basics of creating strings and converting from other data types, to gathering more information and doing some basic manipulation using the native PHP string functions, this article will give you a good base for working with strings in PHP.
Parallel PHP: Running PHP 4 and PHP 5 on the Same Computer - Part 2
Reader Level:
The advances in PHP 5 take the language to a new level, yet most of the world is still running PHP 4. Here's how to have the best of both worlds on one development machine. Part 1 of this article showed you how to add PHP 5 to an existing PHP 4 installation on OS X, and seamlessly switch between the two. Now, Part 2 shows you how to do the same on Windows.
Parallel PHP: Running PHP 4 and PHP 5 on the Same Computer - Part 1
Reader Level:
The advances in PHP 5 take the language to a new level, yet most of the world is still running PHP 4. Here's how to have the best of both worlds on one development machine. Part 1 of this article shows you how to add PHP 5 to an existing PHP 4 installation on OS X, and seamlessly switch between the two. Part 2 will show you how to do the same on Windows.
MySQL Command Line Tips
Reader Level:
MySQL is all the rage these days, and with good reason: its price/power ratio can't be matched. And there are a lot of well-engineered GUI interfaces to make MySQL administration easy. But the fact remains that MySQL's native interface is the command line, and sometimes the command line is the only way to go.
This article walks you through basic MySQL command-line options on diverse operating systems, and shows you how to get up close and personal with MySQL on your local machine
and your remote server.
Working with Times and Dates In PHP
Reader Level:
One of the most common tasks to perform with server-side scripting is the automation of management and site maintenance over time. In this article we'll take a look at how PHP handles time and date values and how they can be used to make your PHP projects more automated and self-reliant.
Creating A Photo Blog in PHP - Part 2
Reader Level:
What good is a blog with no content? Not much good I'm afraid! So today, we will solve your problem of having no content.
Today, we are going to setup the pages that will allow you to not only add new entries, but manage them as well, either through editing existing blog entries, or by deleting ones you don't like.
BBEdit: The Basics and Beyond - Part 2
Reader Level:
In
Part 1 of this article, we toured BBEdit's basic setup and core capabilities and learned why it's widely regarded as a great HTML editor. Part 2 takes BBEdit to the next level, showing you how to leverage its extensibility with AppleScript to create a lean, mean PHP-coding machine, and a perfect partner for Dreamweaver on the Mac.
Dynamic Graphic Menus with PHP
Reader Level:
The trade-off in web design has always been beauty or ease of maintenance. Graphical navigation systems tend to look more appealing than straight text, but are also much more difficult and tedious to maintain and update. However, by utilizing PHP's built-in image manipulation functions, we can now effectively create a graphical navigation system that is both easy to maintain and simple to update...
Creating A Photo Blog in PHP: Part 1
Reader Level:
Doesn't it seem that everyone and their grandma has a blog these days? Blog, blog, blog. That's all people talk about lately.
Today, you and I will use Dreamweaver, and a host of other tools, to start building a different kind of blog. A photo blog!
Curious? Intrigued? Scared? Think you can't do it? I'll bet you Jim's camera that you can! And I'm going to show you how.
Let's get our photo phreak on!
CMX Download Repeat Region Extension
Reader Level:
This extension allows a user to create a downloadable CSV (comma-separated values) or other type of text file that contains the contents of a standard Dreamweaver Repeat Region server behavior (such as a server-side recordset). The extension can also be applied to any server-side content that you want to make downloadable in the browser. This is very useful for creating downloadable files of a results display, such as a product list, a sales report, or a search result.
Manipulating Images On The Fly With PHP
Reader Level:
Server-side scripting has made HTML pages dynamic and adaptable, but for the most part has left the tasks of graphic updates and manipulation up to the hard working web developer. Thanks to the simple, yet powerful, image manipulation functions built into PHP though, those hours of repetitive graphic updates can be spent on better things. This article provides an introduction to PHP's image capabilities and gives you a solid foundation of how to create, work with, and save images from within PHP.
Communicating Between PHP and JavaScript
Reader Level:
One of the great mysteries of web coding seems to be trying to figure out how, if possible, you can pass information from a server-side scripting lanuage (PHP) to a client-side language (JavaScript); and even more elusively, how to pass information back again. In this article, we're going to solve the age old riddle and discover several possible solutions to the problem.
Creating a Simple Blog Part 4
Reader Level:
One of the frequent questions in the forums is "How do I create a blog?". There are many commercial blog systems out there, and many full-featured blog providers, like Blogger, but you can also create a simple blog using the standard tools of Dreamweaver. This tutorial will be equally applicable to ColdFusion, ASP, PHP, ASP.NET, or JSP because we will be using standard Dreamweaver server behaviors to create the blog. This fourth part of the series will describe how to add categories to the blog by modifying the pages you've already created and also how to display the number of comments on each item.
Creating a Simple Blog Part 3
Reader Level:
One of the frequent questions in the forums is "How do I create a blog?". There are many commercial blog systems out there, and many full-featured blog providers, like Blogger, but you can also create a simple blog using the standard tools of Dreamweaver. This tutorial will be equally applicable to ColdFusion, ASP, PHP, ASP.NET, or JSP because we will be using standard Dreamweaver server behaviors to create the blog. Part 3 will focus on adding more features to the blog, such as an RSS feed, individual blog item pages, and how to automatically insert dates.
Creating a Simple Blog Part 2
Reader Level:
One of the frequent questions in the forums is "How do I create a blog?". There are many commercial blog systems out there, and many full-featured blog providers, like Blogger, but you can also create a simple blog using the standard tools of Dreamweaver. This tutorial will be equally applicable to ColdFusion, ASP, PHP, ASP.NET, or JSP because we will be using standard Dreamweaver server behaviors to create the blog. Part 1 of the tutorial can be found at http://www.communitymx.com/abstract.cfm?cid=7CC52. Part 2 will focus on adding more features to the blog, such as a system for adding and viewing comments, and more administration options.
Invitations: The 21st Century Way!
Reader Level:
Traditionally, invitations to an event, such as a wedding or a technology show, are sent out via postal mail. Sometimes, invitations get lost in the process, or they are misplaced by the recipient.
Today, I will show you how to create an RSVP script that will allow you to manage all your RSVPs without having to incur the expense of stamps or worse, lost invitations!
Setting Up A Testing Server For The PHP Server Model: Part II
Reader Level:
In my previous article, we learned how to set up a testing server for the PHP server model. This allows you the opportunity to test your PHP pages locally for bugs and errors in your programming. We also learned how to set up Dreamweaver MX 2004 to use the MySQL testing server you've previously installed. In this second part, we will set up a Graphical User Interface (GUI) so that you can add new databases and tables to your newly installed local MySQL server to further extend your resources.
Setting Up A Testing Server For The PHP Server Model
Reader Level:
Once you have created your site in Dreamweaver MX 2004, you have the option of testing it locally for any bugs, errors or to make changes to the way your pages display in the browser. This is usually done before the site is uploaded to the server. However, in order to test your site locally before uploading, you need to set up a testing server. This article will show you in detail how to setup a testing server in Dreamweaver MX 2004 for the PHP server model.
The Insert Record Server Behavior in Dreamweaver MX 2004
Reader Level:
In this first part of a two-part article, we are going to be looking at Data Insertion using a simple form that we will create in Macromedia Dreamweaver MX 2004.
Inserting data from a form into a database is something we all have done at least once. For instance, signing up to get email alerts from CNN is a great example of inserting data into a database. Or filling out a form on a website to start a magazine subscription. However, the uses don't stop there. In fact, they are limitless.
PHP User Authentication in Macromedia Dreamweaver MX 2004 - Part Two
Reader Level:
The User Authentication behaviour built into Dreamweaver MX 2004 can help do things like password protect sections of your site, such as an administration panel, or other things that you want only specific users to see. As such, the User Authentication behaviour is a great tool for accomplishing this, and today, we are going to cover what makes this behaviour "tick" by taking a quick look at the underlying code.
Installing Apache/ MySQL/PHP on Windows - Part 1
Reader Level:
Have you been thinking about learning PHP or MySQL? Perhaps you've been curious about AMFPHP, the open-source Flash Remoting solution for PHP. In this tutorial, you'll learn an easy way to install Apache, MySQL, and PHP on the Windows platform.
User Authentication in Macromedia Dreamweaver MX 2004
Reader Level:
The User Authentication server behavior built into Dreamweaver MX 2004 can help you password protect sections of your site, such as an administration panel, or other areas that you want only specific users to have access to. As such, the User Authentication server behavior is a great tool for accomplishing this. In Part 1 we will go over setting up the User Authentication login form. In Part 2, we'll take an in depth look at the code produced when we use this behavior in a PHP page, and explain how everything works.
The New Dreamweaver MX 2004 Application Group
Reader Level:
In this article we will look at the new Application group from the currently available Macromedia Dreamweaver MX 2004. The Application group, and its related panels, contain everything you need to start building a database-driven website. Its user friendly interface will make short, and easy, work of working with databases.
Dynamic Letter Anchors extension
Reader Level:
Frequently on a dynamic page that displays a long list of content, such as a list of names, you want to allow a user to jump down to a specific letter of the alphabet. On a static list, this is easy -- just insert anchor links at key places on your page where the first letter of a word changes. On a dynamic page, it is not as easy. Using this extension, you can create a list of links for your data AND create the dynamic anchors to go along with them.
Delivering Browser Specific Styles with PHP
Reader Level:
As an agreed and recognized standard Cascading Style Sheets are an everyday part of a web developer's life. However, many developers still rely on the use of either browser trickery or client-side JavaScript to send the right stylesheet information to the right browser. While this will quite often work, newer browsers, and the ability to disable client-side Javascript means that you run the very serious risk of sending the wrong stylesheet, or even worse, no stylesheet at all.
In this article we explore the use of server-side PHP code in determining which stylesheet should be presented to which browser, and all before your visitor receives anything from your website.