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

(70p] Part II-Implementation-HTML Forms and PHP processing 1. [20p] Use HTML to

ID: 3604384 • Letter: #

Question

(70p] Part II-Implementation-HTML Forms and PHP processing 1. [20p] Use HTML to create a contact form where a user would fill the personal information with the option of saving it to a text file (see Fig. 1) Contact Form First Name: Last Name Address State Not functional yet Not functional yet AL hone Must be functional Emal Must be functional Vinw contati n databar Fig. 1 2. [10p] Create a Thank you" page that the user gets to after successfully submitting the Thanks for Registration! Must be functional information (Fig. 2). Fast Name Je Adke 123 Atereo t dA 314 State Teleptone 912) 123 4567 inad

Explanation / Answer

contacts.html

<div align="center">

<br />

<form id="contact_form" action="file.php" method="POST" enctype="multipart/form-data">

<div class="row">

<label for="firstname">First name:</label>

<input id="name" class="input" name="fname" id="fname" type="text" value="" size="30" required/><br />

</div> <br />

<div class="row">

<label for="lastname">Last name:</label>

<input id="name" class="input" name="lname" id="lname" type="text" value="" size="30" required/><br />

</div><br />

<div class="row">

<label for="Address">Address:</label>

<input id="name" class="input" name="Address" id="Address" type="text" value="" size="30" required/><br />

</div><br />

<div class="row">

<label for="Address">State:</label>

<select name="state" id="state" required>

<option value="All">All</option>

<option value="AP">AP</option>

</select>

</div><br />

<div class="row">

<label for="Telephone">Telephone:</label>

<input id="Telephone" class="input" name="Telephone" type="text" value="" size="30" required/><br />

</div><br />

<div class="row">

<label for="email">Your email:</label>

<input id="email" class="input" name="email" type="text" value="" size="30" required/><br />

</div><br />

<div class="row">

<input id="reset_button" type="reset" value="Reset" />

<input id="submit_button" type="submit" value="Store to database" disabled/>

<input id="submit_button" type="submit" value="Store to file" />

<div>

<div align="center">

<a href="#">View Contacts in Database</a><br>

<a href="file2.php">View Contacts in File</a><br>

</div>

</form>

<div>

file.php

<?php

$myfile = fopen("newfile.txt", "a+") or die("Unable to open file!");

fwrite($myfile,$_POST['fname']);

fwrite($myfile,' ');

fwrite($myfile,$_POST['lname']);

fwrite($myfile,' ');

fwrite($myfile,$_POST['Address']);

fwrite($myfile,' ');

fwrite($myfile,$_POST['state']);

fwrite($myfile,' ');

fwrite($myfile,$_POST['Telephone']);

fwrite($myfile,' ');

fwrite($myfile,$_POST['email']);

fwrite($myfile,PHP_EOL);

fclose($myfile);

echo "<a href="contact.php">Click to Contact page</a>";

?>

file2.php

<?php

$handle = fopen("newfile.txt", "r");

if ($handle) {

while (($line = fgets($handle)) !== false) {

// process the line read.

echo $line."<br>";

}

fclose($handle);

} else {

// error opening the file.

}

echo "<a href="contact.php">Click to Contact page</a>";

?>