I am applying for an internship and they gave me an assignment to complete. They know I have a background in C and have absolutely no experience with PHP. They want me to demonstrate the ability to find the answer to a problem not necessarily demonstrate my knowledge of coding. The following are the parameters of the assignment: Create a form that gathers all the information and sends an email with all info upon submitting it. Form Structure: first_name, last_name, email and phone. All fields should be required. Validate the email. Validate the phone structure. This is a tremendous opportunity for me to learn and gain valuable experience. Any help is truly appreciated. Thanks.
<form action="blah.php" method="post"> First Name: <input type="text" name="first_name" /><br /> Last Name: <input type="text" name="last_name" /><br /> E-Mail: <input type="text" name="email" /><br /> Phone: <input type="text" name="phone" /> </form> PHP: <?php if (isset($_POST['first_name']) && isset($_POST['last_name']) && isset($_POST['email']) && isset($_POST['phone']) && !empty($_POST['first_name']) &7 !empty($_POST['last_name']) && !empty($_POST['email']) && !empty($_POST['phone')) { $errors = array(); if (!ereg("^[^@ ]+@[^@ ]+\.[^@ ]+$", $_POST['email']) { $errors[] = "Invalid E-Mail Address!"; } if (!ereg("((\(\d{3}\)?)|(\d{3}))([\s-./]?)(\d{3})([\s-./]?)(\d{4})", $_POST['phone']) { $errors[] = "Invalid Phone Number!"; } if (!empty($errors)) { foreach ($errors as $error) { echo $error . "<br />"; } } else { echo "First Name: " . $_POST['first_name'] . "<br />"; echo "Last Name: " . $_POST['last_name'] . "<br />"; echo "E-Mail : " . $_POST['email'] . "<br />"; echo "Phone: " . $_POST['phone'] . "<br />"; } } ?> PHP: Kind of sloppy.. and I didn't test the REGEX I just nabbed them from RegexLib.
Now that CodyRo did most of the work for you, don't forget to split the prize money half half. Peace,