Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Create two files named: Form3.php and ValidationFunctions.php in your text ed

ID: 3552032 • Letter: 1

Question

1. Create two files named: Form3.php and ValidationFunctions.php in your text editor.

2.    Using the basic information from your second form, you will now validate various parts of your Form3 input. Use the following info: a) form will redirect to Process1.php upon successfulsubmission; and b) Username will be "CIS108" and have a maxlength of 10, Password will be "PHP" and have a maxlength of 5.

3.    In your Validation Functions Page, create the four necessary functions that check for presence, maximum length, and display correct errors.

4.    Remember to: a) point the form action to the current form; b) require_once both your FormFunctions and FormValidations files at the top of your form; and c) display your error function before the form action.

5.    Now test your form link username/password fields for the following error messages:blank values, mismatched values, and values that are too long. Of course, also test for a successful submission where you will be redirected to Process1.php. I will be testing for each of these validations as well!

6.    Here is a sample of what the Form3 page should look like.

John Smith's Third FORM PAGE

Please log in, Amigo!

Top of Form

First Name:
Last Name:
Username:
Password:

Bottom of Form


Explanation / Answer



<?php require_once('validation.php'); ?>
<html>
    <head>
       </head>
    <body >
        <div id="top">
           <center>Barry Smith's Third FORM PAGE</center>
        </div>
               <center>Please login , Amigo!
                           
            <div id="container">      
            <form action="<?php echo htmlspecialchars($_SERVER["PHP_SELF"]);?>" method="post">
            <label for="username">FirstName:<span>*</span></label>
            <input type="text" id="fname" name="firstname" required><br />
            <label for="username">LastName:<span>*</span></label>
            <input type="text" id="lname" name="lastname" required><br />
            <label for="username">Username:<span>*</span></label>
            <input type="text" id="username" name="username" required><br />
            <label for="password">Password:<span>*</span></label>
            <input type="password" id="password" name="password" required>
            <div id="lower">
            <input type="submit" value="Login" id="bt1" />
            </div>
            </form>
            </div>
                  </center>
    </body>

</html>

//validation.php

<?php
/* Validation.php */


               
        if ($_SERVER["REQUEST_METHOD"] == "POST")
              {
                    if(!empty($_POST['username']) && !empty($_POST['password']))
                    {
                        if((strlen($_POST['username'])<10)||strlen(($_POST['password'])<5))
                            {
                                    header('location:process1.php');
                 
                            }
                           else{
                                                           echo 'wrong username or password';
                                }
                    }
                    else
                    {
                   
                         echo 'please enter username or password';
                   
                    }
        }



?>