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

1. Create two files named: Form1.php and Process1.php in your text editor. 2. In

ID: 3552031 • Letter: 1

Question

1. Create two files named: Form1.php and Process1.php in your text editor.

2.    In your Form Page, create a form action that posts four boxes: First Name, Last Name, Username, and Password. The first three will have a 'text' type, while password will have the 'password' type; all will have blank values. Please put an <h1>Header Label of your choice (see sample output)</h1> above the form action and don't forget <br/> tags! Remember: this page is all HTML code!

3.    In your Processing Page, create a <h1>header label</h1> and then an if-else statement that a) detects form submission and echos that your form was submitted, and b) using ternary operators, sets each of your default values. For the ELSE part, set your First Name and Last Name to your names and the Username and Password to blank values. Finally, display your full name on one line and your username/password on the next line (using a separator of your choice). If you run this file on it's own (as a GET rather than POST), you should see your name.

4.    Now create two new files: Form2.php and FormFunctions.php. Using the basic information from your first form, point the action to Form2. At the top of the file, create some php code that sets your username and password. Create a set of nested if-else statements (as in video 3) that will successfully redirect you to your Process1.php page if your Username is CIS108 and Passwordis PHP. Give the appropriate messages for an erroneous username/password and logging in the first time and don't forget to echo the message before your form action.

5.    As in the video, create the appropriate redirect function in your FormFunctions file....you only need this one function. Remember to require_once this file at the top of your Form2 page!

6.    Here is a sample of what the Form1 page should look like. and a sample of the Form2 page.

Explanation / Answer

//Here is your Form2.php


<html>

<head>


</head>

<body>

<h1>Enter Your Info In Given Form(Second Form Page):</h1><br/>

<form action="FormFunction.php" method="POST">

<span>First Name :</span><input type="text" name="fname"/><br/>

<span>Last Name :</span><input type="text" name="lname"/><br/>

<span>Username :</span><input type="text" name="username"/><br/>

<span>Password :</span><input type="password" name="pass"/><br/>

<input type="submit" name="submit"/>

</form>

</body>

</html>


//Here is FormFunction.php

<?php

$USER="";

$PASS="";

if( isset($_POST['submit']))

{

$USER = $_POST['username'];

$PASS = $_POST['pass'];

}

if($USER=="CIS108"&&$PASS=="PHP")

{

echo "Redirecting you :<br/>";

header('Location: Process.php');

die();

}

else

{

echo "entered username or password are wrong.";

}


?>