Welcome! Log In Create A New Profile

Advanced

Task 3B

Posted by Reinie 
Announcements Last Post
Announcement SoC Curricula 09/30/2017 01:08PM
Announcement Demarcation or scoping of examinations and assessment 02/13/2017 07:59AM
Announcement School of Computing Short Learning Programmes 11/24/2014 08:37AM
Announcement Unisa contact information 07/28/2011 01:28PM
Task 3B
March 19, 2007 03:05PM
Completed
Re: Task 3B
March 19, 2007 03:21PM
Completed.
Re: Task 3B
March 24, 2007 03:56PM
Done.
Re: Task 3B
March 25, 2007 11:18PM
Ok so i'm stuck at the Exc 3-1 on page 36-37 of masterskill the guest book exc.

Cant seem to see the guest book entry that i punched in on guestbookform.php when i click to verify it just shows up as

:

and no text, any idea where i could be going wrong?
avatar
Mac
Re: Task 3B
March 26, 2007 07:55AM
Post some code. It could be anywhere....
Re: Task 3B
March 26, 2007 09:59PM
This is my code in guestbookform.php

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">;
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<?php
$title = "WebBooks.com Guestbook";
include("header.php"winking smiley;
?>
<table border='0' width='600' cellspacing='0' cellpadding='0'>
<tr>
<td><p><b>WebBooks.com Guestbook:</b></p>

<form method='post' action='guestbook.php'>
What is your first name? <input name='firstname' type='text'><br>
What is your last name? <input name='lastname' type='text'><br><br>
What comments do you have about this site?<br>
<textarea name='comments' rows='6' cols='45'>
</textarea><br><br>
<input type='submit'>
</form>

<b>Entries in the Guestbook:</b></br>
<?php
include("./guest.txt"winking smiley;
?></td>
</tr>
</table>

<?php
include("footer.php"winking smiley;
?>

</body>
</html>

-------------------------------------
This is my code in guestbook.php
-------------------------------------

<?php
$title = "WebBooks.com Guestbook";
include("header.php"winking smiley;

$fp = fopen("./guest.txt", "a"winking smiley;
fwrite($fp, "<br><b>$firstname $lastname:</b> $comments<br>"winking smiley;
fclose($fp);

echo "Your entry has been added to the guestbook!<br><br>";
echo "<a href='guestbookform.php'>Return to the Guestbook</a>";
?>

-----------------------------------------
Basically i'm following the book as per instructions and i know i'm probably missing something vital.I'm even having a slight hiccup with my directory, the only thing that does'nt want to open is Test/
Re: Task 3B
March 26, 2007 10:29PM
Completed
avatar Re: Task 3B
March 27, 2007 04:01AM
Kaajal

I had the same errors until I realised that this was missing from my code in guestbook.php:
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$comments=$_POST['comments'];

After I added it, everything worked okay.
Regards
Dot Khoza

A Successful Nature Inspires Other People...
avatar Re: Task 3B
March 27, 2007 04:03AM
My code in guestbook.php looks like this:
<?php
$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$comments=$_POST['comments'];
$title = "WebBooks.com Guestbook";
include("header.php"winking smiley;

$fp = fopen("./guest.txt", "a"winking smiley;
fwrite($fp, "<br /><b>$firstname $lastname:</b> $comments <br /> "winking smiley;
fclose($fp);
echo "Your Entry has been added to the guestbook!<br /><br />";
echo "<a href='gbform.php'>Return to the Guestbook</a>";
?>

Enjoy coding!!

A Successful Nature Inspires Other People...
Re: Task 3B
March 27, 2007 06:09PM
Task completedgrinning smiley

Is it better to use 'require' instead of 'include', when using external files?
Re: Task 3B
March 27, 2007 06:29PM
This task is completed successfully.

Had to add

$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$comments=$_POST['comments'];

I agree, it is better to use 'require' instead of 'include', when using external files.
Re: Task 3B1 - Creating a Hit Counter
March 27, 2007 06:41PM
Completed Successfully
Re: Task 3-1 - Building a Guestbook Application
March 27, 2007 06:43PM
This task is completed successfully.

Had to add

$firstname=$_POST['firstname'];
$lastname=$_POST['lastname'];
$comments=$_POST['comments'];

I agree, it is better to use 'require' instead of 'include', when using external files.
Re: Task 3B
March 27, 2007 10:05PM
Yay my guestbook application works, Thanks Dotkhoza. smile
Re: Task 3B
April 14, 2007 10:19PM
All Good,

Got a bit more involved and added to Guestbook.php :-

$firstname = $_POST['firstname'];
if($firstname == ""winking smiley $firstname = "Not Supplied";
$lastname = ($_POST['lastname']);
if($lastname == ""winking smiley $lastname = "Not Supplied";
$comments = ($_POST['comments']);
if($comments == ""winking smiley $comments = "None";

just so you dont get blank entries in your file. And to display what i was posting to the file :-

echo "<p><b> The data you have supplied is :-</b></p>";
echo "First Name :- ".$firstname."<br>";
echo "Last Name :- ".$lastname."<br>";
echo "Your Comments :- ".$comments."<br><br>";


Also changed the file name from "guest.txt" to "guest.html" as we are writing HTML commands to the file, would be easier to read the file in a browser window instead of a text viewer.

In hit_number.php, added this bit to ignore the read of file, if the file does not exist on the first pass, and set the $currenthits counter to zero.

if($fp = fopen("./hit.txt", "r"winking smiley)
{
// Read 20 binary bits from the text file and place in $currenthits variable
$currenthits = fread($fp, 20);
fclose($fp);
}
else
{
$currenthits = 0;
}

Otherwise , all thumbs up , time 4 a smileys with beer
Re: Task 3B
April 24, 2007 11:17AM
Done.hot smiley
Re: Task 3B
April 24, 2007 06:53PM
Done.
Re: Task 3B
April 28, 2007 05:02PM
Done.

thumbs up smiley
Re: Task 3B
May 12, 2007 05:46PM
Done
Sorry, only registered users may post in this forum.

Click here to login