Back to Top
The nuts and bolts for
Creative web development

PHP Back to Basics #10: String Handling in PHP

Ever had problems taking user input, submitting it to a database then not getting back the result you expect?

 

If you have, then this tutorial might make your life a whole lot easier. In this next installment of PHP Basics, Gareth takes us through some of the PHP string handling commands that can help you manage, and format, user input and database output.

 

You'll learn how to work with variable capitalization, input of unexpected characters that can affect your carefully constructed SQL and how to extract portions of text from a record.

Author: Gareth Downes-Powell Price: $3.59 Rating: Not enough votes

PHP Back to Basics #9: Working with Objects

In this tutorial, we look at what classes and objects are, and how they can be used to make your code more organized, with the benefit that they can easily be shared between people and projects. We then see how a class is defined, and how to add properties and methods to the class, as well as how to use a constructor function which is run automatically when a new object is created from the class.

 

Finally, we create an example class that can be used to easily generate HTML tables, so you only have to setup the appearance of the table such as its width, border etc, and the class does the hard work of actually generating the HTML code to create the table.

Author: Gareth Downes-Powell Price: $3.59 Rating: Not enough votes

PHP Basics: Cookies and Sessions

In this tutorial we're going to look at how to use cookies and session variables in PHP, to allow you to save data for the user as they move between pages. This can be used for a number of different uses such as for creating a log-in system to secure your site, or saving data for a user's shopping cart, for example.

Author: Gareth Downes-Powell Price: $3.59 Rating:

PHP Basics 7: Connecting to a MySQL Database

Dreamweaver MX contains a number of server behaviors for connecting to a MySQL database and performing database operations, these can be quite limiting and if you want to build a truly powerful website you really need to be able to hand code the database operations yourself. Once you can do this all limits are removed and you're no longer limited in what you can achieve!

 

 This tutorial covers:

Building a Database 
Creating a table - users 
Adding Data to the Users table 
Working with a MySQL database 
Connecting to the MySQL Server 
Select Database 
Execute MySQL Query 
Close Server Connection 
PHP Commands for Working with the MySQL database 
Connecting to the MySQL Server 
Select Database 
Execute SQL Query 
Close Server Connection
Working Examples 
Reading Records from a Database 
Adding Records to a Database 
Modifying Records in a Database 
Deleting a Record from the Database

Author: Gareth Downes-Powell Price: $3.59 Rating:

PHP Basics: email contact forms

Have you ever wanted a contact form on your website that will automatically email you, instead of leaving a mailto: address? Or maybe a form that the user controls via radio buttons that is directed to the correct person by the logic?

It's easy in PHP, and Gareth shows you how in this article, going through every step - setting up the mail headers, the forms and the PHP code.

Author: Gareth Downes-Powell Price: $3.59 Rating:

PHP Basics: Forms, GET and POST

In this beginner's tutorial, Gareth shows the options available in HTML forms via Dreamweaver and how to retrieve data passed via a form through the GET and POST methods, and discusses the difference between these different ways of passing user data.
Author: Gareth Downes-Powell Price: $3.59 Rating:

PHP Back to Basics: Functions

In this tutorial, we're going to look at using functions in PHP. Functions allow you to lay out your code in a more organized way, and allow you to easily re use your code, saving you time, and making your projects easier to read and debug.

 

We’re going to look first at what functions are, and how they can be used. We then look at how to create a function in your code, and how to make the function accept arguments which can then be used in the function code. Next, we see how to return a value from a function to the calling code, so that the result can then be output or sent for further processing.

 

In the second part of this tutorial we look at the scope of variables, and how variables from your main code can be read or changed from within a function. Finally, we look at using the static command which can save the data held in variables between function calls.

Author: Gareth Downes-Powell Price: $3.59 Rating: Not enough votes

PHP Back to Basics 3: Arrays

In this tutorial we will be looking at arrays, which are extremely widely used in PHP. Data is often returned in the form of an array, for example when you read records from a database, or reading the data entered into an HTML form which has been submitted by the user.

We'll start by looking at what exactly an array is, and then look at the methods which can be used to create or add data to an array. We then look at the various ways you can work with data held in the form of an array, working through each element of the array in turn, and merging the data from two arrays into one.

Finally, we look at sorting data held in an array, so that the data is transformed into alphabetical or numerical order.

Author: Gareth Downes-Powell Price: $3.59 Rating: Not enough votes

PHP: Password Encryption and Retrieval

If you're running a system that password-protects sensitive data, you'll also want to encrypt the passwords themselves in case anyone hacks your server and reads the password database. Allan runs through the various options available in both MySQL and PHP, dealing with one-way encryption and methods of decrypting passwords so that password reminders can be sent to the user, for example.

This tutorial stands alone, but can also be optionally used to extend the registration and confirmation suite that we built previously (part 1, part2, part 3).

 

Please note that this article forms part of a chapter in the DMXzone e-book PHP Web Applications for Dreamweaver: Juicy Solutions for the Busy Developer.

 

Author: Allan Kent Price: $3.59 Rating:

PHP: Site Registration and Confirmation Completed

Over the last two tutorials, we have been building up a user registration and validation system using as much of Dreamweaver's built in functionality as possible. We have built our database and created a form with validation for capturing the users' details, and then sent the user a confirmation email and written a script that tests for a human user and validates them against the database. We also wrote a small script that lets us test our system without having to send emails all over the place. This week we'll finish off our system by creating a small addition to our users.php script, add some functionality for the user to reset their password if they have forgotten it and then create a set of login pages that works with the database structure that we created in the first tutorial.

 

All the code for a full PHP log-in and confirmation suite is included with this tutorial!

 

Please note that this article forms part of a chapter in the DMXzone e-book PHP Web Applications for Dreamweaver: Juicy Solutions for the Busy Developer.

Author: Allan Kent Price: $3.59 Rating:

PHP Basics - conditions and loops

In this tutorial we look at conditional processing and the different commands available in PHP to perform this. Conditional processing allows you to choose which parts of your code are run depending on certain conditions, such as data entered by a user or results from a database.

 

In the second part of this tutorial, we move on to look at loops in PHP. We first look at the PHP for loop, which enables you to repeat a section of code a certain number of times, to perform calculations or to display rows of dynamic output.  We then look at the other types of loop such as the do loop and do … while loop which come in useful in a range of different situations.

 

Finally, we look at nested loops, which are loops within a loop. These are extremely useful for creating HTML tables, and have a number of different uses such as laying out photos in an online photo gallery.

Author: Gareth Downes-Powell Price: $3.59 Rating: Not enough votes

PHP: Site registration and confirmation with a Validation code Image

In the second part of this series on building a registration and confirmation suite in PHP, Allan builds a testing script so that you can test the pages without being logged on or using a SMTP server, and builds a Validation Code Image display and checker, similar to the one illustrated, so that you can be sure that it's a real person registering, and not an automated script.

 

Please note that this article forms part of a chapter in the DMXzone e-book PHP Web Applications for Dreamweaver: Juicy Solutions for the Busy Developer.

Author: Allan Kent Price: $3.59 Rating: