Question: In this project, you will create a script that uses regular expressions to validate that an e-mail address is valid for delivery to a user
In this project, you will create a script that uses regular expressions to validate that an e-mail address is valid for delivery to a user at example.org. For an e-mail address to be in the correct format, only username or first.last may appear before the @ symbol, and only example.org or mail.example.org may appear after the @ symbol.
You will be evaluated on the basis of all coding conventions including adding comments before every functions and author/param.
1. Create a new document in your text editor. 2. Type the declaration, element, document head, and
element. Use the strict DTD and Validate Local Address as the content of theValidate Local Address
4. Add the following script section to the document body: 5. In the script section, declare an $email array that contains five e-mail addresses: $email = array( "jsmith123@example.org", "john.smith.mail@example.org", "john.smith@example.org", "john.smith@example", "jsmith123@mail.example.org"); 6. Add the following statements to iterate through each of the elements in the $email array to determine if it is in the correct format: foreach ($email as $emailAddress){ echo "The email address “" . $emailAddress . "” "; if (preg_match("/^(([A-Za-z]+\d+)|" . "([A-Za-z]+\.[A-Za-z]+))" . "@((mail\.)?)example\.org$/i", $emailAddress)==1) echo " is a valid e-mail address."; else echo " is not a valid e-mail address."; } 7. Save the document as ValidateLocalAddress.php in the Projects directory for Chapter 3 and upload the file to the server. 8. Open ValidateLocalAddress.php in your Web browser by entering the following URL: http://
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
