Managing Dependencies with Composer

Composer is a package manager for PHP much like gem is for ruby or npm is for node. It allows you to define libraries that your application depends on and will install them for you as well a their own dependencies. It also includes an autoloader to load classes in both the installed packages as well as your own classes. Installation The easiest way to install composer on a Mac or Linux based OS is to run one of the following commands from a terminal. This will download a file into the current…
Read More →

Building a simple contact form in PHP - Part 5

In of part 4 of Building a simple contact form in PHP we added a CAPCHA field to help reduce spam. In this part we are going to change the sending of the mail to use SMTP by using Swift Mailer, a php mailing library. As we left it our contact form looked like this. Add the SMTP credentials to your configuration file I am using a gmail account as an example. Change the server, port, username, and password to whatever the settings for your email account are. Adding the Swiftmailer library Head…
Read More →

Building a simple contact form in PHP - Part 4

In of part 3 of Building a simple contact form in PHP we added client-side validation to our form. In this part we are going to add a CAPTCHA field to the form in order to reduce spam. We have validation to help prevent blank form submissions but there is still nothing to stop spam bots from sending a bunch of junk posts via some automated script. A common way of reducing spam is by adding a CAPTCHA field to the form. These are those fields with the distorted random characters that you need to…
Read More →

Building a simple contact form in PHP - Part 3

As we last left it in part 2 of Building a simple contact form in PHP we added server-side form validation to our contact form and input filtering to the submitted data before sending out the email. In this part we are going to add some client-side validation to our contact form. This is the contact form as we left it. Why Add Client-Side Validation? It is important to keep in mind that client-side validation doesn't not provide any extra security for your application. Circumventing it is as…
Read More →

Building a simple contact form in PHP - Part 2

In part 1 of Building a simple contact form in PHP we built a simple contact form that sends a notification when the form is posted with the values the user posted. As we discussed at the end of part 1 there are a few problems with our contact form. We are going to work on solving some of those problems. The is what the contact form looked like as we last left it. Adding Form Validation Right now a user is able to submit a blank form and an email will still be sent. We are going to add some…
Read More →

Building a simple contact form in PHP - Part 1

In this series we will be building a simple contact form in php. It will cover sending emails and form validation. Creating the Contact Form We will start with the form itself. Save the following as contact.php We will also add a stylesheet with some basic styles for the form. Save the following as styles.css If you view the page in a browser it should look something like this. Not the prettiest form but this isn't a design tutorial. Feel free to add your own styles. We also will need a page to…
Read More →
Copyright © 2022 - Jonathan Bernardi