Explore the Premium Content

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.

Read More

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.

Read More

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.

 

Read More

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.

Read More

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.

Read More

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.

Read More

PHP: Registration and confirmation email system part 1

If you’ve ever tried to register on a web site to use a forum or download the trial version of a product, you may have come across a registration system that emails you a message that you have to respond to before your login or account is activated. Today we’re going to start taking a look at how we can go about creating such a system. We’ll build the interface in Dreamweaver, but by the very nature of what we’ll be doing we will also need to spend some time in the Code View. This article is divided into three parts. The contents of both articles are;

    1. Enter your details in a web form
    2. Submit the form to the web site
    3. Wait for confirmation email
    4. follow instructions in confirmation email, usually a link to click
    5. Log in to site with confirmed login and password

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.

    Read More

    ASP.NET: Uploading an Image and creating a thumbnail

    During the course of this tutorial you will learn how to provide users with the facility to upload files to a remote server using an HTML form; specifically this tutorial will focus on uploading image files to an Images directory and saving a proportionally-sized thumbnail of the uploaded images in a Thumbs directory. The code presented here is able to identify if an image is landscape or portrait and adjust the dimensions of the generated thumbnail accordingly. This is a very common scenario on a typical e-commerce site where a product list page would show the thumbnail images and the detailed product info page would show the larger image. This tutorial demonstrates how to code the ASP.NET for uploading gif and jpg files.

    Read More

    PHP - Back to Basics part 1

    After a number of requests, in this series we’re going to back to basics and will look at PHP from a beginner’s point of view. If you’re looking to expand your knowledge of PHP, and want to move beyond what the default server behaviors etc that Dreamweaver MX offers, to create more advanced sites, then this is the series for you, so that you can get to grips with PHP and really understand what's happening when you begin to handcode and add more powerful features to your web pages.

    First, were going to look at how PHP actually works, and how the PHP code is processed on the web server, and how the web server knows which sections of the page represent PHP code. We then move on to look at the order in which certain PHP operations should be placed on the page, so that they can be processed in a logical order.

    In the second half of this tutorial we look at how to create simple output using PHP, and setup variables which can be used to hold values which change during the course of the script. We then look at a range of different operators which can be used to work with the values in variables, ready for the next part of this tutorial where we will be looking at conditional processing.

    Read More

    PHP/ CSS Advanced Image Gallery part 4

    In last week's article we added some functionality to our admin page and altered the main gallery page so that users of your site could search for images and then click through to view a full-size image.  In this weeks article we will add some cool functionality to our gallery so that when a user clicks on a thumbnail to a full-size image, they can navigate through all the other images without having return to the main thumbnail gallery.

    A few loose ends are tidied up, and the result is a fully-functional image gallery using PHP and CSS - no tables - with all the code attached for download.

     

    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.

    Read More

    Role based user authentication 2

    Welcome to the continuation of the last article I wrote, ASP: Role-based User Authentication. Previously, we looked at a way to provide role based authentication in a generic manner. We linked modules of functionality to users through four roles: Read, Add, Update, and Delete. We also provided ‘blanket’ Full access without explicitly storing a record for each of the roles. As this article follows on from last time, I highly suggest you read that article first – but it's not compulsory, as the code is provided.

    Today, we’re going to create a simple web-based administration tool for managing these permissions. For the sake of brevity, I won’t go through all the pages such a tool would have, I’ll concentrate on the two pages that tie it all together.

     

    All the code is provided, as usual, in the code download link below the PDF buttons.

    Read More

    PHP/ CSS Image Gallery part 3

    In last week's article, " Thumbnailing a Portion of an Image ", we took a look at how we could alter our image gallery to provide an interactive way of creating a thumbnail from our uploaded image. In this week's tutorial we will do two things: first we will alter our gallery admin page so that we can see at a glance whether an uploaded image has a thumbnail or not and provide a link from the admin page to create or recreate thumbnails, and then we will revisit the main gallery page again and alter it to display the thumbnails of the images with click-throughs to the larger images that the thumbnail represents.

    It helps if you've read the previous article in this series, and hoping that you have read "PHP/ CSS Searchable Image Gallery" as well - but it's not compulsory, as all the code is provided.

     

    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.

    Note: Check also the DMXzone own CSS Image Gallery extension for amazing pure CSS galleries and slideshows with a fluent navigation and image transitions! 

    Read More
    Newer articles Older articles