Basic Forms with PHP

HTML forms are a great way to collect information directly from your users. There are plenty of input options available, even for the most basic, non-javascript enhanced forms. This post will go over the steps for creating, validating, and handling an elementary contact form with PHP and HTML.

We'll have to make a few basic assumptions before beginning. First, we'll assume that the page the form is displayed on can be executed with PHP. This could mean that either the page has a 'php' extension or the web server is configured to run this file as PHP, regardless of the file extension. Second, we'll assume that there is no conversion tracking (that is, analytics tracking the number of page visits vs the number of form submissions). This will make our submit logic a bit simpler. Finally, we will not be doing any javascript or ajax trickery. All the fields and submit request are handled as browser defaults.

Our initial step involves setting up a basic html form. We'll be submitting via the 'post' method, which passes the form parameters ...

read more »

Mount Arvon

Mount Arvon is the highest point in the state of Michigan. At 1979' above sea level (1380' above Lake Superior), it slowly rises out of the Baraga County forest on the northern end of the Peshekee Highlands. I had avoided visiting this mountain, more interested in the rocky outcroppings of the Huron Mountains to the north and east, but I finally gave in with a combination of curiousity and convenience.

Mount Arvon peak

Mount Arvon peak

After searching for an upper drop on the Ravine River (which doesn't exist), I continued south and west on Ravine River Road. This remote logging road slowly winds it's way up the northern face of the mountain to within a 1/2 mile of the peak. The drive was pretty neat, with a small creek cutting a deep gorge right off the edge of the two-track, and it did most of the elevation gain for me. The road made a sudden stop after a sharp right turn, so I parked my car and headed bast the rock-and-concrete barricade.

Road barricade at Mount Arvon

Road barricade at Mount Arvon

The two-track up the mountain remained ...

read more »

Connecting to a MySQL Database with PHP

Working directly with the database is something I rarely do any more with the applications I work with. Instead of creating a raw connection and pulling data directly, I usually utilize some sort of customized data layer. (If you don't know what a data layer is, imagine creating a PHP application with no queries. You still have data being pulled, usually from MySQL table, but the data storage and structure is kept independent of your application. When done correctly, this can help immensely with code cleanliness and development.) However, setting up a connection and pulling information is still an important skill set, so here is a post about the basics. If you're looking for information that is more basic than a PHP-MySQL connection, you can read my series on the basics of the SQL language.

There are several ways to connect to a table, but I'd highly recommend using the MySQL Improved Extension, or mysqli, as a simple but powerful way to connect to your MySQL ...

read more »