In this lesson we will explore ways to further validate inputted data.
We will start with the preg_match() function. We have added a new elseif statement to our previous document as shown here.
We can use the preg_match() function to test whether a string meets a specified pattern.
In our case, we will test to make sure the Name only contains letters and whitespace. This will prevent someone from typing in numbers in the First Name input.
We have also added another elseif statement with a preg_match() function that checks to make sure the inputted website is in the correct format. For example, www.mywebsite.com.
Let's test out our script to see the result.