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

In this project, you will create a Web page that allows visitors to your site to

ID: 3712760 • Letter: I

Question

In this project, you will create a Web page that allows visitors to your site to sign a guest book that is saved to a text file. Ensure that the Projects directory has read and write permissions for everyone.


1. Create a new document in your text editor and type the <!DOCTYPE html> declaration, <html> element, document head, and <body> element. Use “Guest Book” as the content of the <title> element.


2. Add the following text and elements to the document body:



3. Save the document as GuestBook.html.


4. Create a new document in your text editor and type the <!DOCTYPE html> declaration, <html> element, document head, and <body> element. Use “Sign Guest Book” as the content of the <title> element.


5. Add the following script section to the document body:


<?php


?>


6. Add the following if statement to the script section to check whether the user filled in the first name and last name fields:



7. Add the following else clause to the end of the script section. The statements in the else clause use the fwrite() function to add visitor names to a text file named guestbook.txt.



8. Save the document as SignGuestBook.php.


9. Create a document named ShowGuestBook.php that displays the names of visitors who have signed the guest book. Use the readfile() function to display the contents of the guestbook.txt file. Note that you will need to use the <pre> element (https://www.w3schools.com/tags/tag_pre.asp) for Web browsers to recognize the line breaks.


! DOCTYPE html> html lang-"en"> ?head> title>Guest Bookk/title> body> h2>Enter your name to sign our guest book ?form method-"POST" action-"SignGuestBook.php"> First Name Kinput type-"text" name-"first name">X/p>

Explanation / Answer

If you have any doubts, please give me comment...

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>GuestBook</title>

</head>

<body>

<h2>Enter your name to sign our guest book</h2>

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

<p>First Name <input type="text" name="first_name" /></p>

<p>Last Name <input type="text" name="last_name" /></p>

<p><input type="submit" value="Submit" /></p>

</form>

<p><a href="ShowGuestBook.php">Show Guest Book</a></p>

</body>

</html>

SignGuestBook.php

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>Sign Guest Book</title>

</head>

<body>

<?php

if(empty($_POST['first_name']) || empty($_POST['last_name']))

echo "<p>You must enter your first and last name. Click your browser's Back button to return to Guest Book.</p> ";

else{

$FirstName = addcslashes($_POST['first_name']);

$LastName = addcslashes($_POST['last_name']);

$GuestBook = fopen("guestbook.txt", "ab");

if(is_writeable("guestbook.txt")){

if(fwrite($GuestBook, $LastName.", ".$FirstName." "))

echo "<p>Thank you for signing our guest book!</p>";

else

echo "<p>Cannot add your name to the guest.<p>";

}

else

echo "<p>Cannot write to the file.</p> ";

fclose($GuestBook);

}

?>

</body>

</html>

ShowGuestBook.php

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<title>Show Guest Book</title>

</head>

<body>

<?php

echo "<pre>".readfile("guestbook.txt")."</pre>";

?>

</body>

</html>

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote