how to view a guestbook!!

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
joyce
Forum Newbie
Posts: 6
Joined: Fri Apr 16, 2004 1:02 am

how to view a guestbook!!

Post 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 :P
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

wow ......... haha

show us some code?
Illusionist
Forum Regular
Posts: 903
Joined: Mon Jan 12, 2004 9:32 pm

Post by Illusionist »

It might be helpful if you find a forum in your own langauge.
User avatar
John Cartwright
Site Admin
Posts: 11470
Joined: Tue Dec 23, 2003 2:10 am
Location: Toronto
Contact:

Post by John Cartwright »

[Edited;

Due to the fact that it didn't add anything useful to this thread, whatsoever.

--JAM]
joyce
Forum Newbie
Posts: 6
Joined: Fri Apr 16, 2004 1:02 am

Post 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]
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

What's the error code you're getting back?
Post Reply