Very simple guestbook script/software?

Soldato
Joined
1 Sep 2005
Posts
10,001
Location
Scottish Highlands
Im after some very simple guestbook type software. It needs to be able to run without MySQL and be able to fit into a html/css page without too much trouble. Ive tried a few, but none of them work how I want. The closest I have found is one that used flash and php, but unfortunately it didn't seem to work properly. Any suggestions?
 
Cheers guys. That one looks perfect Tom. When I try it though, it throw up errors, do you know about these? I should be on MSN later tonight, so i'll grab it off you then. :)
 
That one seems to work a treat Tom, cheers. Ive now managed to fit the guestbook into my site and it seems to work pretty well. However there seems to be a slight problem with my page in IE6. It works fine in Opera and Firefox. The problem is the top flash element not showing properly. Ive tried to figure out what the problem is, but I can't seem to find it. So are there any glaringly obvious errors in the code?

Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">


	<head>
		<title>Alasdair Fowler Photography</title>
		<link rel="stylesheet" type="text/css" href="mystyle.css"/>
	</head>

<body> 
	<div align="center">	
		<script type="text/javascript" src="swfobject.js"></script>

		<div id="pinstripesides">
			<div id="monoSlideshow1">
				<p><strong>Please install Flash and turn on Javascript.</strong></p>
			</div>
		
				<div align="center" id="navbar">
					<ul>
					<li><a href="index.html">Home</a></li>
					<li><a href="About.html">About</a></li>
					<li><a href="Messages.html">Messages</a></li>
					<li><a href="Links.html">Links</a></li>
					<li><a href="Contact.html">Contact</a></li>
					</ul>
				</div>

				<div id="content">

					<?php 
					//No Page Caching 
					Header('Cache-Control: no-cache'); 
					Header('Pragma: no-cache'); 

					require "include.php"; //require include file, creates fatal error over include function 

					//Start Session 
					if (session_start() <> True) { 
 					session_start(); 
					} 
					if (isset($_SESSION['allowed']) == False) $_SESSION['allowed'] = "FALSE"; //Admin Session 

					Switch (GetPost("p")) // Page Switching 
    					{ 
        				// ********* Default Page - Gets Comments/Replies ********* 
        				default:  
            			echo htmlHeader(); //echos html headers 
        				?> 

            			<div id="guestbook"><h1>Post A Comment</h1> 
                				<form action="index.php?p=comment" method="post" id="PostForm"> 

                    			<div> 
                        			<ul> 
                            			<li>Name<br/><input type="text" name="comName"></input></li><br/> 
                            			<li>Email<br/><input type="text" name="comEmail"></input></li><br/> 
                            			<li>Comment<br/><textarea name="comCom"></textarea></li><br/> 
                            			<li><input type="submit" value="Post Comment"/>&nbsp;<input type="reset" value="Clear"></li>                              
                       				</ul> 
                    			</div> 

                				</form>

                 				<div id="LoginContainer"><h1>Admin Section</h1>                         
                					<?php 
                					if ($_SESSION['allowed'] == "FALSE") //Not logged in, display loging form 
                    				{ 
                					?> 

							<div id="guestbook">
                    					<form action="index.php?p=admin" method="post" id="LoginForm"> 
                        				<div> 
                            					<ul> 
                                				<li>Username<br/><input type="text" name="adminUser"></input></li><br/> 
                                				<li>Password<br/><input type="password" name="adminPass"></input></li><br/> 
                                				<li><input type="submit" value="Login"/></li> 
                            					</ul> 
                        				</div> 
                    					</form> 
							</div>

                					<?php 
                    				} else { //Logged in, display logout form 
                					?> 

                    				<form action="index.php?p=logout" method="post"> 
                        			<div> 
                            				<ul> 
                                			<li><input type="submit" value="Logout"/></li> 
                            				</ul> 
                        			</div> 
                   				</form> 

				            	<?php 
                    				} 
                					?>     
                				</div> 
            			</div> 
             			<div id="guestbookcomments">
        					<div id="CurrentComments"> 
            					<h1>Comments</h1>         
						</div> 
             
        						<?php //***********Comment retrival PHP****************** 
       						$strdirectory = getcwd()."/data/"; //Gets current working directory, adds the directory data to it 
         
        						// Get comment files in comment (data) directory 
        						$strFiles = array(); 
        						$handle = opendir($strdirectory) or die("Directory not found!"); //Opens directory 
         
        						while($entry = readdir($handle)) //Scans through, uses an array to sort out files and subdirs 
            					{ 
                					if(!is_dir($entry) && $entry != ".." && $entry != ".") 
                    				{ 
                        			$strFiles[] = $entry; 
                    				} 
            					} 
             
        						closedir($handle); //Close handle for directory 
        						sort($strFiles); //Sorts files/directory 
        						$intComCount = count($strFiles); //number of comments (actually files) 
         
        						//Entries numbers 
        						echo "<div id=\"Entries\">"; 
        						if($intComCount > 0){ 
            					if($intComCount == 1){ 
                					echo "1 Entry"; 
            					} else { 
                					echo "$intComCount entries"; 
            					} 
        						} else { 
            					echo "Currently there are no entries in the guestbook.<br/>How about posting a comment?"; 
        						} 
        						echo "</div>"; 
         
        						//Generates comment information 
        						for($i=0; $i < $intComCount; $i++) //Goes through comment files, displays them 
            					{ 
            					displaycomment($strdirectory . $strFiles[$i], $i, $strFiles[$i]); 
            					} 
            					break; 

         
        						//**********************Form Page for Reply ************** 
        						case "reply": 
            					echo htmlHeader(); 
							?> 

            					<div id="guestbook">
								<h1>Post a Reply</h1> 
                						<form action="index.php?p=reply2" method="post" id="PostForm"> 
                						<input type="hidden" name="filenumber" value="<?php echo GetPost("file"); ?>"> 
                    					<div> 
                        					<ul> 
                            					<li>Name<br/><input type="text" name="replyName" class="textentry"></input></li><br/> 
                            					<li>Email<br/><input type="text" name="replyEmail" class="textentry"></input></li><br/> 
                            					<li>Comment<br/><textarea name="replyComment" class="textentry"></textarea></li><br/> 
                            					<li><input type="submit" value="Post Reply"/>&nbsp;<input type="reset" value="Clear"></li> 
                        					</ul> 
                    					</div> 

								<?php 
            						break; 

             
        							//*******************Redirection from Reply form********************* 
        							case "reply2": 
            						if (writeReply(GetPost("filenumber"),GetPost("replyName"), GetPost("replyEmail"), GetPost("replyComment")) != FALSE) 
            						{ 
                						header("Location: http://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/index.php"); 
            						} else { 
                						echo htmlHeader(); 
                						echo "An Error has occured, Please go back a check the entered data!<br/>"; 
                						echo "<A HREF='javascript:history.go(-1)'>Go Back</A>"; 
            						} 
            						break; 
             
        							case "comment": 
            						if (writeComment(GetPost("comName"), GetPost("comEmail"), GetPost("comCom")) != FALSE) 
            						{ 
                						header("Location: http://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/index.php"); 
            						} else { 
                						echo htmlHeader(); 
                						echo "An Error has occured, Please go back a check the entered data!<br/>"; 
                						echo "<A HREF=\"javascript:history.go(-1)\">Go Back</A>"; 
            						} 
            						break; 
         

        							//********************* ADMIN LOGIN *****************8         
        							case "admin": 
            						//Admin Username and Password 
            						$strUsr = "CHANGEME"; 
            						$strPass = "CHANGEME"; 
             
            						if (GetPost("adminUser") == $strUsr && GetPost("adminPass") == $strPass) 
            						{ 
                						$_SESSION['allowed'] = "TRUE"; 
                						header("Location: http://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/index.php"); //redirect back to main page 
            						} else { 
                						echo htmlHeader(); 
                						echo "An Error has occured, Please go back a check the entered data!<br/>"; 
                						echo "<A HREF='javascript:history.go(-1)'>Go Back</A>";     
            						} 
            						break;     

             
            						//*****************ADMIN LOGOUT*****************     
            						case "logout": 
                						session_destroy(); //deletes all sessions 
                						header("Location: http://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/index.php"); //redirects back to main page 
                						break; 
                 
             
            						//*************DELETE COMMENT************* 
            						case "delete": 
                						if ($_SESSION['allowed'] == "TRUE" && GetPost("file") != "")  
                						{ 
                    					$strDelFile = getcwd()."/data/".GetPost("file").".txt"; 
                    					$fh = fopen($strDelFile, 'w') or die("can't open file"); //Make sure we have complete access to file, isn't already open etc 
                    					fclose($fh); 
                    					if (unlink($strDelFile) == TRUE) 
                    					{ 
                       					header("Location: http://".$_SERVER['HTTP_HOST'].rtrim(dirname($_SERVER['PHP_SELF']), '/\\')."/index.php"); //redirects back to main page                     
                    					} else { 
                        				echo htmlHeader(); 
                        				echo "An Error has occured deleting a comment, Please go back and try again!<br/>"; 
                        				echo "<A HREF='javascript:history.go(-1)'>Go Back</A>";     
                    					} 
                						} 
                						break;                     
								} 
								?>     
							</div>
						</div>
					</div>
	
					<script type="text/javascript">
					var fo = new SWFObject("monoslideshow.swf", "FOmonoSlideshow", "800", "100", "7", "#000000");
					fo.addVariable("showLogo", "false");
					fo.addVariable("dataFile", "monoslideshow2.xml");
					fo.write("monoSlideshow1");
					</script>

					<div id="footer">
						<div id="footertext">
							<p>All images and content are the copyright of Alasdair Fowler</p>
						</div>		
					</div>
				</div>
			</div>
		</div>
	</div>
</body>
http://www.afowler.co.uk/index.php

Alsoi what is controlling the size of the gaps between the sections (Admin Section, Comments) etc? And finally, where do I set the Admin password and username? Sorry for the noob questions, but im slowly getting there.
 
Cheers SiriusB. I thought I already had changed the CSS file.. weird :/. I still can't find whats defining the large gap between the sections as there aren't any divs in the CSS with such a large padding, but i'll keep looking. And the password section was a bit obvious wasn't it.:o

Im not going to attempt it until im happy with the rest of the stuff that needs doing, but how would I go about making a php equivalent of frames? The reason I ask is that each time I click on a new page, the flash element at the top reloads. Ideally I would want the flash element to be persistant and just the bottom content to change. Im guessing this can be done by making a dynamic php page that simply changes its contents when a link is clicked, rather than a whole new page loading. But im not entirely sure where to start with this. Anyone got any pointers or examples of this?
 
That script works a treat tsinc80697. :) you can see it on http://www.afowler.co.uk/ under the 'messages section'. Just a couple of questions about it though;

What sections do I need to change with the style sheet to change the colour of the message posters name, and also the reply link? And more importantly, how would I go about having the newest messages at the top? Would it also be a huge job making it so that after say 20 messages, they go over onto a new page with a link "show next 20" etc?
 
Back
Top Bottom