this practice assignment wants me to: Create a document named ShowGuestBook.php that dis- plays 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 element for Web browsers to recognize the line breaks. here is my two PHP files and my html codes. I am getting an ( ! ) Parse error: syntax error, unexpected 'POST' (T_STRING) on SignGuestBook.php on line 10! i cant seem to figure out whats the issue , help please!! GuestBook.html Guest Book Enter your name to sign our guest book First Name Last Name Show Guest Book SignGuestBook.php Sign Guest Book You must enter your first and last name. Click your browser's Back button to return to the Guest Book.\n"; else { $FirstName = addslashes($_POST['first_name']); $LastName = addslashes($_POST['last_name']); $GuestBook = fopen("guestbook.txt", "ab") if (is_writeable("guestbook.txt")) { if (frwite($GuestBook, $LastName . ", " . $FirstName . "\n")) echo "Thank you for signing our guest book!\n"; else echo "Cannot add your name to the guest book\n"; else fclose($GuestBook); echo "Cannot write to the file.\n"; } } ?> ShowGuestBook.php Show Guest Book
this practice assignment wants me to: Create a document named ShowGuestBook.php that dis- plays 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 element for Web browsers to recognize the line breaks.
here is my two PHP files and my html codes. I am getting an ( ! ) Parse error: syntax error, unexpected 'POST' (T_STRING) on SignGuestBook.php on line 10! i cant seem to figure out whats the issue , help please!!
GuestBook.html
<!DOCTYPE>
<html>
<head>
<title>Guest Book</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>
<head>
<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 the Guest Book.</p>\n";
else {
$FirstName = addslashes($_POST['first_name']);
$LastName = addslashes($_POST['last_name']);
$GuestBook = fopen("guestbook.txt", "ab")
if (is_writeable("guestbook.txt")) {
if (frwite($GuestBook, $LastName . ", " . $FirstName . "\n"))
echo "<p>Thank you for signing our guest book!</p>\n";
else
echo "<p>Cannot add your name to the guest book</p>\n";
else fclose($GuestBook);
echo "<p>Cannot write to the file.</p>\n";
}
}
?>
</body>
</html>
ShowGuestBook.php
<!DOCTYPE>
<html>
<head>
<title>Show Guest Book</title>
</head>
<body>
<?php
echo readfile("guestbook.txt")
?>
</body>
</html>
Actually, given information regarding php.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps