Action: Create a functions.php file

We just learned about reusing code. There are certain functions that you use over and over again. Create a functions.php file that contains the basic functions you use. Here is a list of the ones you should put in the file to start. You can add others as you need to.  Connect to the database.…

Read More

How to Add PHP pages to WordPress

First, duplicate post.php or page.php in your theme folder (under /wp-content/themes/themename/). Rename the new file as templatename.php (where templatename is what you want to call your new template). To add your new template to the list of available templates, enter the following at the top of the new file: <?php /* Template Name: Name of…

Read More

Doing Something With The Form

In the last topic, we learned how to link a form in an HTML document to a PHP script and how to use that script to access the data that the user had typed into the form. However, once we had the data – all we did was echo the results of the form fields…

Read More

String Functions

There are lots and lots of functions in PHP that do fun things with strings. These can be very useful in parsing data. Here’s a full list at at w3schools.com. We will take a look at a few specific ones. We’ll use these strings in these examples. $text1 = “Today is” $text2 = “a very…

Read More

Passing Info In Your URL’s Querystring

There are a few ways to pass data between web pages: Global variables like $_SESSION or using cookies. Form inputs using the $_POST global variable Or via the querystring. What is the querystring? Here’s the standard definition from Wikipedia: A query string is a part of a uniform resource locator (URL) that assigns values to…

Read More

Storing Your Passwords Safely!

Obviously you need to keep your website secure and what is one of the key ways of gaining access?  Hacking in with an easy to guess password.  It is very important to keep your passwords safe especially when you need to use them in code such as opening a SQL database. Hashing is the accepted…

Read More

Reusing Code

One of the primary purposes of using functions is to allow code to be reused.  How do you do this in PHP?  By placing code that will be reused in separate file or library and then using either the include() or require() function to place it in your code. What is the difference between the…

Read More

Parsing Data into Database

Okay – this is critical.  We need at least a sample in so that we can work on the algorithm.  This needs to get done…now.  Basically all you need to do is look at how we did it back in Lesson 8: Updating, Inserting and Deleting Data with PHP Lesson 8: Updating, Inserting and Deleting…

Read More

Basic Math & String Operators

Operators are basically tools that allow you to do things with the values in your program including your variables. Math Operators + addition – minus * multiplication / division Incrementing/Decrementing Operators PHP supports some fun ways to increase or decrease a variable by the amount of 1. This can be very useful for counters or…

Read More