Page 1 of 1
how to view a guestbook!!
Posted: Sun Apr 18, 2004 8:21 pm
by joyce
hi, i want to know how to view a guestbook on the homepage!!
i know how to view the guestbook when i sign in my guestbook.
i do a homepage got sign in the guestbook and view the guestbook.
when i sign in the guestbook, they will let you know that you had sign in.
then must include what i want to view my guestbook? i got put include sign.php but not working.how ?
thankx

Posted: Sun Apr 18, 2004 8:24 pm
by John Cartwright
wow ......... haha
show us some code?
Posted: Sun Apr 18, 2004 8:40 pm
by Illusionist
It might be helpful if you find a forum in your own langauge.
Posted: Sun Apr 18, 2004 8:50 pm
by John Cartwright
[Edited;
Due to the fact that it didn't add anything useful to this thread, whatsoever.
--JAM]
Posted: Mon Apr 19, 2004 12:15 pm
by joyce
This is my code
Code: Select all
<?php
// create short variable names
$name=$HTTP_POST_VARS['name'];
$location=$HTTP_POST_VARS['location'];
$email=$HTTP_POST_VARS['email'];
$url=$HTTP_POST_VARS['url'];
$comments=$HTTP_POST_VARS['comments'];
if (!$name || !$location || !$email || !$url || !$comments)
{
echo 'You have not entered all the required details.<br />'
.'Please go back and try again.';
exit;
}
$name = addslashes($name);
$location = addslashes($location);
$email = addslashes($email);
$url = addslashes($url);
$comments = addslashes($comments);
@ $db = mysql_pconnect('localhost', 'root');
if (!$db)
{
echo 'Error: Could not connect to database. Please try again later.';
exit;
}
mysql_select_db('joyce');
$errmsg = "";
if (empty($name))
{
$errmsg .= "<li>You have to put in a Name, at least\n";
}
if ($email != "")
{
$email = htmlentities($email);
$email_checker = explode("@", $email);
if (!IsSet($email_checker[1]))
{
$errmsg= "$email doesn't look like a valid email address";
}
else
{
//email checked
}
}
$query = "INSERT INTO guestbook
SET name='$name',
location='$location',
email='$email',
url='$url',
comments='$comments'";
$result = mysql_query($query);
$query="Select * from guestbook;";
$result = mysql_query($query);
$num_results = mysql_num_rows($result);
if ($result)
echo $num_results.'<b> guest had signed up the guestbook.</b>';
for($i=0; $i <$num_results; $i++)
{
$row = mysql_fetch_array($result);
echo '<p><strong><br />Name: </strong>';
echo htmlspecialchars(stripslashes($row['name']));
echo '<strong><br />Location: </strong>';
echo stripslashes($row['location']);
echo '<strong><br />Email: </strong>';
echo stripslashes($row['email']);
echo '<strong><br />Url: </strong>';
echo stripslashes($row['url']);
echo '<strong><br />Comments: </strong>';
echo stripslashes($row['comments']);
echo '</p>';
}
?>
[Edit: Added PHP tags for eyecandy. --JAM]
Posted: Wed May 12, 2004 2:19 pm
by patrikG
What's the error code you're getting back?